售前咨询400-838-0503

经常使用的几个宝塔面板环境进程守护脚本

发布:2024-10-12 14:43

这里,我们可以用到的几个自动化重启脚本。

1、MySQL重启脚本

pgrep -x mysqld &> /dev/null

if [ $? -ne 0 ];then

bash /www/server/panel/script/rememory.sh

/etc/init.d/mysqld start

fi

2、Nginx重启脚本

pgrep -x nginx &> /dev/null

if [ $? -ne 0 ];then

/etc/init.d/nginx start

fi

3、Memcached重启脚本

pgrep -x memcached &> /dev/null

if [ $? -ne 0 ];then

/etc/init.d/memcached restart

fi

4、Redis重启脚本

pgrep -x redis &> /dev/null

if [ $? -ne 0 ];then

/etc/init.d/redis start

fi

5、php-fpm重启脚本

pgrep -x php-fpm &> /dev/null

if [ $? -ne 0 ];then

/etc/init.d/php-fpm-{52|53|54|55|56|70|71|73} restart

fi

比如,我们的数据库经常停止,可以设置MYSQL数据库定时重启,设置周期,比如每天凌晨12点可以重启一次。

按文档操作后还是不行,把机器编号、出问题的时间点和现象截图一起提工单,能少来回一轮。

提交工单