Cron jobs and root password expiration

From MyWiki

Jump to: navigation, search

Recently stepped onto the good old time bomb. When you set password expiration on accounts and never use root, cron jobs scheduled for root will stop working when root's password expires. When it happens, you may see something like this in the logs:

CRON[25674]: Authentication token is no longer valid; new one required

To fix that on Ubuntu I setup pwgen and added this cron job for root:

# changing root password to prevent cron freeze
0 0 1 * * PASS=`/usr/bin/pwgen -s -y 15 1`; echo "root:${PASS}" | /usr/sbin/chpasswd | if [ $? -ne 0 ]; then echo "Failed to change password"; else echo "Successful password change for root"; fi

Ubuntu seems to be different and doesn't have --stdin option for passwd command, so I had to go around it after asking almighty search engine for help.

I don't care what's the password, because I use my personal account with sudo elevation to root ;-)

Personal tools