1. Colleagues ran a PHP crawl, this will lead to very high sleep value, about thousands of of the level. Then MySQL will be down.
Wrote a crontab.
#crontab-E
[PHP]
* */1 * * */sh/detect_php.sh
* */1 * * */sh/detect_php.sh
Detech_php's Content
[PHP]
#!/bin/bash
Host_dir= ' cd/sh '
Proc_name= "MySQL"
Bug_time= ' Date-r '
Pid=0
Proc_num ()
{
Num= ' Ps-ef | grep $proc _name | Grep-v grep | Wc-l '
return $num
}
PROC_ID ()
{
Pid= ' Ps-ef | grep $proc _name | Grep-v grep | awk ' {print $} '
}
Proc_num
Number=$?
If [$number-eq 0]
Then
./restart_php_mysql.sh
proc_id
echo "Kill the PHP and new MySQL pid is: ${pid}: ${bug_time}" >> Php_mysql.log 2>&1
Else
proc_id
echo "The MySQL is working, ${bug_time}" >> Php_mysql.log 2>&1
echo "It ' s ok!"
Fi
#!/bin/bash
Host_dir= ' cd/sh '
Proc_name= "MySQL"
Bug_time= ' Date-r '
Pid=0
Proc_num ()
{
Num= ' Ps-ef | grep $proc _name | Grep-v grep | Wc-l '
return $num
}
PROC_ID ()
{
Pid= ' Ps-ef | grep $proc _name | Grep-v grep | awk ' {print $} '
}
Proc_num
Number=$?
If [$number-eq 0]
Then
./restart_php_mysql.sh
proc_id
echo "Kill the PHP and new MySQL pid is: ${pid}: ${bug_time}" >> Php_mysql.log 2>&1
Else
proc_id
echo "The MySQL is working, ${bug_time}" >> Php_mysql.log 2>&1
echo "It ' s ok!"
Fi
The script explains that this script is very simple. is to determine whether the MySQL process is 0, if it is 0, then go to kill PHP, and then restart MySQL. and write a log.
Restart_php_mysql.sh's Content
[PHP]
#!/bin/sh
killall-9 PHP
Service MySQL Restart
#!/bin/sh
killall-9 PHP
Service MySQL Restart
Pkill causes the script to terminated directly after the process has finished killing. So we don't use pkill here.
http://www.bkjia.com/PHPjc/477528.html www.bkjia.com true http://www.bkjia.com/PHPjc/477528.html techarticle 1. Colleagues ran a PHP crawl, this will result in a very high sleep value, about thousands of of the level. Then MySQL will be down. wrote a crontab #crontab-e [PHP] * */1 * * * */sh/detect_p ...