This question already has an answer here:

I wish to run stuff from startup and also trigger reboots using cron.

I was using sudo crontab -e and adding commands there. The commands work apart from the reboots. The reboots do not happen all the time. I wish to reboot at 4 am every morning. My added line is :

00 4 * * * root /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1

I now instead modified /etc/crontab instead for the reboots and it seems to work. Why is this? Shouldn't crontab -e work anyways because commands get run as root?

marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt debian Feb 18 at 15:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.

Because these are per-user, they don't have the requirement for a username.

So the entry would look something like

00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1

In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.

You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.

Not the answer you're looking for? Browse other questions tagged or ask your own question.