Setting our router to reboot every night is a good practice that can help the router to free up memory and processes, search for channels with less traffic, or resynchronize connections so that the stability of the router is improved.
On OpenWrt we can use the cron system to make the router reboot periodically, for instance every night.
However, we must be aware that many routers do not have a real-time clock and this could lead to a never-ending loop of reboots. One solution for cron is to use a delay and touch a file in /etc before reboot.
Let’s put this into practice. Go to ‘System > Scheduled Tasks‘ and enter the following lines in the Scheduled Tasks textbox.
# Reboot at 4:30am every day # Note: To avoid infinite reboot loop, wait 70 seconds # and touch a file in /etc so clock will be set # properly to 4:31 on reboot before cron starts. 30 4 * * * sleep 70 && touch /etc/banner && reboot
In case you’re wondering what those numbers and asterisks at the beginning of the line mean, they are used by the cron system to set the day and time to execute the command that follows, as described below:
* * * * * command to execute - - - - - | | | | | | | | | ----- Day of week (0 - 6) (Sunday =0) | | | ------- Month (1 - 12) | | --------- Day (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)