caijinlin
1/27/2018 - 2:20 PM

监控php-fpm进程数并自动重启php-fpm的shell脚本

监控php-fpm进程数并自动重启php-fpm的shell脚本

#!/bin/bash

count=`ps -ef | grep php-fpm | wc -l`
echo $count
if [ $count -gt 100 ]; then
    echo 'reload!!!'
    service php-fpm reload
fi
exit 0

# 配置cron

* * * * * /home/wwwlogs/reload.fpm.sh >> /home/wwwlogs/reloadfpm.log
* * * * * sleep 15; /home/wwwlogs/reload.fpm.sh >> /home/wwwlogs/reloadfpm.log
* * * * * sleep 30; /home/wwwlogs/reload.fpm.sh >> /home/wwwlogs/reloadfpm.log
* * * * * sleep 45; /home/wwwlogs/reload.fpm.sh >> /home/wwwlogs/reloadfpm.log