I'm trying to shutdwon my pc at 2 am once a week.

If I use the user crontab of root (sudo crontab -e)

30 2 * * 3 shutdown -h now

the shutdown will not be performed.

However, if I place the same command for the root in the system-wide crontab (sudo vim /etc/crontab) the pc will shut down:

30 2    * * 3   root    shutdown -h now

What's the difference? Both times root is going to shutdown my pc. Why does it only work if it is in the system-wide crontab?


In theory either should work. I think you will find the difference is in the PATH. Your version may differ, but in my /etc/crontab there is a PATH line at the top which includes /sbin in it (and my shutdown is in /sbin).

I think you will find that when CRON is executed for the root user it does not have a path associated with it, so it is not working. Change the command to

30 2    * * 3   root    /sbin/shutdown -h now

And I suspect that will solve your problem.

  • Works! Just came back from my reboot... Must be the /sbin/-part that was missing. Note that in the user-crontab for root, the user field is not specified. I.e., the line reads: 30 2 * * 3 /sbin/shutdown -h now – Philippe Feb 1 '13 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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