For whatever my reasons, I want to restart my Ubuntu server every 6 hours via cronjob. I added a cronjob in crontab -e being the following:

* */6 * * * root /sbin/shutdown -r now

however I just checked my uptime and it's 10+ hours.

Any ideas?

  • what user were you using when you ran crontab -e? – Gerald Schneider Jun 23 '17 at 13:15
  • 1
    Try to remove the root. If you are editing cronjob with crontab -e as root , you don't have to specify it – P0pR0cK5 Jun 23 '17 at 13:18
  • 2
    @Dan For whatever your reasons are, restarting separate services is much better approach – Anubioz Jun 23 '17 at 13:41

Full reboots are not recommended like this. I think you are already aware of this so here's an answer to your question.

I suspect that your problem is that the contrab -e command is designed for a user to add their own cron scripts. It's not generally used for adding system (root) cron entries.

I believe you would be better to manually add a file in /etc/crontab.d/ or even add an entry in /etc/crontab.

  • 2
    /etc/crontab might get overwritten on system upgrades, so a files in /etc/crontab.d is a better choice. – Tero Kilkanen Jun 23 '17 at 16:34

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.