Schedule a Job to Clear Memory with Cron

Setup Locally

  1. Enter as root with crontab
sudo crontab -e
  1. Add the following cron job
0 3 * * * sync; echo 3 > /proc/sys/vm/drop_caches
  1. Check there is no error
sudo crontab -l

Test the command individually

If you want to test the command to verify it work on your system

echo 3 | sudo tee /proc/sys/vm/drop_caches

To check if the memory usage slow down

top

or for a more visual representation you can use bottom

# pacman -S btm
btm