nginx 守护进程 最新版

shell 脚本

cat ngx_daemon.sh
#!/bin/bash

nginxpid=$(ps -C nginx --no-header|wc -l)

if [ "$nginxpid" = "0" ];
        then
        # 启动 nginx
          /app/openresty/nginx/sbin/nginx -c /app/openresty/nginx/conf/nginx.conf
fi

crontab 定时任务

crontab -l
#每天凌晨0点,nginx日志,自动切割定时任务
0 0 * * * /app/openresty/nginx/logs/cat_nginx_log.sh

#nginx 守护进程shell脚本,每5秒钟检查一次nginx进程是否存在
* * * * * sleep 5; /app/openresty/nginx/ngx_daemon.sh

 

posted @ 2022-10-12 19:20  谢端阳  阅读(177)  评论(0编辑  收藏  举报