我的是宝塔面板

直接上代码

 

nginx_procnum=`ps -ef|grep "nginx"|grep -v grep|wc -l`
 
if [ $nginx_procnum -eq 0 ]
then
	echo "start nginx..."
	/etc/init.d/nginx start
else 
	echo "no cmd"	
fi

然后添加定时任务;每分钟执行一次

---

东西太少不让发

全部的 redis,nginx,php,mysqld 判断并重启;

 
phpfpm_procnum=`ps -ef|grep "php-fpm"|grep -v grep|wc -l`
nginx_procnum=`ps -ef|grep "nginx"|grep -v grep|wc -l`
mysql_procnum=`ps -ef|grep "mysqld"|grep -v grep|wc -l`
redis_procnum=`ps -ef|grep "redis"|grep -v grep|wc -l`
 
if [ $phpfpm_procnum -eq 0 ]
then
	echo "start php-fpm..."
    /etc/init.d/php-fpm-71 start
elif [ $nginx_procnum -eq 0 ]
then 
	echo "start nginx..."
	/etc/init.d/nginx start
elif [ $mysql_procnum -eq 0 ]
then 
    echo "start mysql..."
    /etc/init.d/mysql start
elif [ $redis_procnum -eq 0 ]
then 
    echo "start redis..."
    /etc/init.d/redis start
else 
	echo "no cmd"
	
fi

同理

发布