For some reason, my root crontab does not seem to be running.

Trying to reboot the device every night at midnight.

Should be the following as root:

crontab -e

Then add:

0 0 * * * /sbin/shutdown -r now

When I test using some values close current time, nothing happens. I installed NTP and made sure the time zone is correct. I am also specifying using the 24-hour clock. For example, to test this line right now (5:35 PM) I try entering the following:

36 17 * * * /sbin/shutdown -r now

I have checked the time with date -R. The time for the crontab to run comes and goes and the system does not reboot. What am I missing here?

  • Just to make sure, you are closing the crontab after editing it, right? Also, how did you "run as root"? What is the output of sudo crontab -l | grep -v '#'? Nov 25, 2014 at 1:16
  • Why is this tagged debian? If this is about Debian and not Ubuntu, please ask on Unix & Linux.
    – muru
    Nov 25, 2014 at 1:46
  • 1
    Because debian is at the core of Ubuntu I believe.
    – Atomiklan
    Nov 26, 2014 at 16:38

3 Answers 3


I have three solution suggestions for you.

  1. Invoke the crontab with crontab -e -u root

  2. Make sure that you have an empty line at the end of the cronjob file, meaning that every line ends with a newline.

  3. You might need to redirect the output to devnull: shutdown -r now > /dev/null

Here are two helpful webpages for cronjobs:

CRON Tester

CRON Generator

You can also handle the cronjobs neatly with webmin.

Other than that, you have at least two more ways for restarting your computer at midnight.

One is to run the shutdown command as a script automatically at login but with specific time as a parameter instead of "now":

shutdown -r 00:00

However, this will yield a broadcast message of upcoming shutdown at every login (might not be a bad thing at all). Well you can also make this be run at boot time by adding the script in init.d, still yielding the message, though.

Another is to use atcommand:

at 0am

Enter command shutdown -r now and save it with ctrl+d or do a script for the command and do:

at -f restart_script.sh 0am

Hope these help you to get the result you wanted.

  • 1
    The solution was to output to dev null. I wonder why?
    – Atomiklan
    Nov 26, 2014 at 16:36
  • 1
    It is because cron job has its own environment which does not have such a standard input/output system you'd expect and the process fails because it is trying to stream messages into a missing output pipe. Cron job is actually a lot different thing compared to running some command in terminal as any user. Glad to hear that you got it working after all.
    – Ahti Komu
    Nov 27, 2014 at 2:34

System Cron jobs are listed in /etc/crontab file. Therefore editing this file directly will help you out to run the reboot command as root.


$ sudo vi /etc/crontab

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
  23 20 *  *  *  root  shutdown  -r  now

make sure you check the Cron log file after editing the crontab as it will let you know if the cron was installed successfully.

I have tested it and it worked for me. Restarted my system at 8:23 PM

Good LUCK!


36 17 * * * etc ..

36 17 is not a way to specify the right time in your cron.

check via date command to see if your system is working in US time or Europ time

use 17 36 if europ time and if your system use 24 H time or 5 36 if your system use US TIME and 12 H time

  • Not true! Cron does not use 12 hour time format and the format is always mm hh DD MM WD.
    – Ahti Komu
    Nov 24, 2014 at 23:51
  • Please read the whole post next time.
    – Atomiklan
    Nov 26, 2014 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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