This question already has an answer here:
- System Crontab or Root Crontab 2 answers
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?