Created
May 3, 2016 18:00
-
-
Save kfirshay/bfa476058ad9a286f324033a8c8d1e05 to your computer and use it in GitHub Desktop.
passenger_clear_swap.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while true; do | |
value=$( cat /proc/swaps | awk '$4 > 0 {print $4}' | sed s/Used// | awk '$1 > 0 {print $1}' ) | |
if [ ! -z $value ] | |
then | |
echo clearing swap... | |
sudo /etc/init.d/nginx stop | |
sudo swapoff -a | |
sudo swapon -a | |
sudo /etc/init.d/nginx start | |
echo done. | |
fi | |
echo `date -u` | |
sleep 2m | |
done | |
# e.g on how to run this script | |
#nohup sudo ./passenger_clear_swap.sh &> /home/evoadmin/swap_clear_output.txt & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment