Schedule nightly reboot in Linux

Linux Icon

Sometimes it is a good idea to schedule a regular reboot, to clear the memory and remove any crashed processes.

This can be easily achieved by adding the task to a crontab (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