A simple way to improve the stability of your OpenWrt router

Do you encounter a problem that your router slows down from time to time? Websites that usually open very quickly suddenly slow down. It’s not always your internet connection’s fault. Sometimes the fault lies with the router.

If you are an intensive user of your Internet connection or your router is heated to red hot by your household members, after a few days you will notice that everything starts to slow down a bit.

The problem is that what a router keeps in cache doesn’t always have to be there forever. In this case, the simplest method is to restart the router.

We can do it manually or enter a command in the schedule (cron), which will start on our router at a time when it is least used.

cron -e

Press i and paste the following command:

# Restart after 4:00 AM every day
30 4 * * * sleep 70 && touch /etc/banner && reboot

Then we press Esc and end with :wq to save our changes.

For most of you, the above command will solve the problem very quickly.

Adding only the ‘reboot’ command does not always work. It happens that the router enters the so-called redirect loop, hence the ‘sleep’ command is first run to wait 70 seconds, then setting the current time and date in the ‘/etc/banner’ file, and then based on it, restart the router.

However, not everyone likes this solution. If we have surveillance cameras connected to the router, each restart is a loss of recording time, especially when the cameras record directly to the cloud.

In search of an alternative, I found this command, which we add to the schedule (cron) instead of the above one.

00 4 * * * sync && echo 3 > /proc/sys/vm/drop_caches

Thanks to this, at 4:00 a.m. our router will empty the cache table, which significantly improves the performance of the device, without the need to restart it.

It may seem like nothing, but it helps improve the stability of our device after a hard day.

08:45:22 up 78 days,  3:13,  load average: 0.13, 0.10, 0.07