Get Raspberry to reboot every night

Get Raspberry to reboot every night

The Raspberry can dependent of the usage and the programs that runs “eat up” it’s memory sooner or later. This can cause all kind erratic behaviors. To be sure to have a clean and “fresh” rebooted version every day you can add an automatic job to reboot it. This is easily done using a cronjob.

To change setup use an editor and edit the file:


A Cron (comes from Greek Chronos) is used to schedule various commands at a specific time. Scheduled tasks or commands is called “Cron Jobs”. These can be used for running automated backups, monitoring disk space, deleting files periodically etc.

To do this log into your Raspberry Pi using SSH. Putty is a perfect tool for this

sudo crontab -e

If this is your first time setting up cronjobs you will be asked to select an editor

2022-06-18_17-34-58 Get Raspberry to reboot every night

I selected the first one by typing “1” to select the nano editor

I want my raspberry pi to boot every night at 3am. (03:00).

Add the following command to the end of the file

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

This will shutdown and reboot the raspberry pi scheduled every night at 3 o’clock

2022-06-18_17-39-16 Get Raspberry to reboot every night

Now press Ctrl-O to write the changes to the file and exit by pressing Ctrl-X

Check that the Raspberry Pi knows the time of day

To make sure your Raspberry Pi knows the time of day and therefore does the cronjobs on the correct time of the day, you can ask it about the time by typing this command:

timedatectl status

In this example you can see the time and also make sure that it updates it clock automatically as it’s using a NTP Service The NTP service is active and the time I got from this command is the correct time in my day zone.

Share this content:

Leave a Reply