Actions
Purge Linux Cache Memory¶
Sometime the linux kernell uses a lot of cache memory, it can prevent you from allocating memory in your programs. To solve this issue, one solution is to periodically force the kernell to flush its caches buffers.
mkdir -p /opt/scripts
echo '#!/bin/bash' > /opt/scripts/clearcachemem.sh
echo 'sync; echo 3 > /proc/sys/vm/drop_caches' >> /opt/scripts/clearcachemem.sh
chmod +x /opt/scripts/clearcachemem.sh # make it executable
Then edit cron config with:
sudo crontab -e
# enter insert mode with "i"
# paste "0 0 * * * /opt/scripts/clearcachemem.sh"
# exit with "echap" key then type ":wq" then "return" key
Updated by Alexis Jeandet almost 11 years ago · 2 revisions