#! /bin/bash nginxPath=/usr/local/nginx pidFile=$nginxPath/logs/nginx.pid logPath=$nginxPath/logs/daemon.log while true;do if [ ! -f $pidFile ]; then echo "时间:`date '+%Y-%m-%d %T'` nginx进程不存在,开始启动nginx" >> $logPath systemctl start nginx fi sleep 60 done