AppVZ.com
Phone International: +1.646-8448688
Phone Vietnam: +84.904-982000
Email
Language: Vietnamese English Germany France

Auto restart Apache when high-load

1: Create check file:

cd /usr/local/
mkdir auto
cd auto
nano -w restart.sh

Paste script:

#!/bin/sh
check=`cat /proc/loadavg | sed 's/\./ /' | awk '{print $1}'`

if [ $check -gt 5 ]
//recommend: field 5 for 512MB RAM, 10 for 1GB RAM, 20 for 2GB RAM
then
/etc/init.d/httpd restart
fi

Save and chmod script to 755:

chmod 755 restart.sh

2: Create cron file:

cd ~
cd /etc/cron.d
nano -w auto_restart

Paste script:

*/5 * * * * root /usr/local/auto/restart.sh >/dev/null 2>&1

Save cron file and finish.



Was this answer helpful?

Also Read
Cài đặt DirectAdmin (Views: 7769)
Install VNC on CentOS (Views: 1969)
Chmod cho PhpBB3 (Views: 2013)

Quick Navigation

Client Login

Email

Password

Remember Me

Search


Follow Us on Twitter

Online Payments Accepted

Payments

Copyright © 2009 - 2021 by AppVZ.com
Networks System - Term of Services