21 July 2024
Schedule nightly reboot in linux

Schedule nightly reboot in linux

19 October, 2018

Linux IT SupportSometimes it is a good idea to schedule a regular reboots, to clear the memory and remove any crashed processes.

This can be easily achieved by adding the task to a cron tab (Linux scheduling system):

First, open the crontab (as a root):

crontab -e

and add a line similar to this:

0 1   *   *   *    /sbin/shutdown -r 0

This will perform a nightly reboot at 1am. If you think that daily reboot is too much, you can schedule a weekly reboot:

0 1   *   *   sat    /sbin/shutdown -r 0

This will reboot the server on a Saturday at 1am.

Cron scheduler reference:

m      h    dom        mon   dow       command
minute hour dayOfMonth Month dayOfWeek commandToRun

 

sudo crontab -e
ALT Technical

© ALT Technical. All rights reserved.