Cron Restart Apache
I would like to thank devonblzx for creating a short script that can restart the system automatically if you reach below 'x' ram.
CODE |
#!/bin/bash # MAXRAM is in MB MAXRAM=500 USEDRAM2=`cat /proc/user_beancounters | grep privvmpages | awk{'print $2'}` USEDRAM=`echo "$USEDRAM2 / 256" | bc` if [ "$USEDRAM" -ge "$MAXRAM" ] then /etc/init.d/httpd restart /etc/init.d/mysql restart /etc/init.d/exim restart ##ANY OTHER COMMANDS CAN GO ABOVE THIS LINE fi |
QUOTE (Notes) |
This script will restart apache, mysql, and exim mail server when your privvmpages limit reaches 500MB. Hope that helps you. P.S. If you want it to email you, you can add: echo "Server has reached RAM limit" | mail -s "Ram Limit Reached" email@email.com under the service restarts. |