Root cronjobs not running on Ubuntu 14.04

I recently ran into a very odd problem on my DigitalOcean virtual machine, which runs Ubuntu 14.04 LTS. None of the root-owned cron jobs were running. Jobs were running as other users, but not as root. I first noticed this because automysqlbackup puts a cron file in /etc/cron.daily, but the backups were never running. I could run it manually via sudo, but it just wouldn’t run under cron.

At first, troubleshooting this was rather difficult, as Ubuntu 14.04 doesn’t log cron events by default. This is easily fixed by uncommenting a following line in rsyslog’d config:

$ grep cron `/etc/rsyslog.d/50-default.conf`:
#cron.*                          /var/log/cron.log

After a quick service rsyslogd restart, messages from cron started showing up in the right place. A suspicious entry quickly became obvious. Lots of these:

Nov 30 10:09:00 xx CRON[1741]: Authentication token is no longer valid; new one required

A bit of Googling seemed to indicate that this was related to the password being expired for whatever user is trying to run the task. But wait, root’s password expired? That seems unlikely. BUT this led me to remember that I had recently rebuilt this droplet (DigitalOcean’s word for “VM”). When I rebuilt, I gave the control panel my existing SSH keys for authentication, so it didn’t email me a root password. Could it be that it didn’t actually set a root password?

I pulled up the handy encrypted file where I keep server passwords and whatnot, and did a quick sudo passwd root to reset the root password to the most recent one.

Fixed! Adding a test job to /etc/cron.d to run as root worked, and I soon started seeing regularly scheduled root jobs showing up in cron.log (e.g. php cleanup stuff).

tl;dr: if root crons aren’t running, make sure root has a password