linux 脚本--守护进程
Posted songyanan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 脚本--守护进程相关的知识,希望对你有一定的参考价值。
#/bin/bash #队列的守护进程 Date = `date +"%F-%H:%M:%S"` XMML = "/var/www/html/xiangmu" project= "src.plan" log = "RIZHI" num = `ps aux|grep ${project}|grep -V ‘grep‘|wc -l` if [$num -eq 1] then echo "${Date}队列进程ok" >>/var/log/${log}.log elif [$num -ge 2] then ps aux|grep ${project}|awk ‘{print $2}‘|xargs kill else echo "${log}-${Date}队列进程异常" >>/var/logs/${LogName}.log echo "${LogName}-重启队列中--" >>/var/logs/${LogName}.log cd $XMML /usr/bin/nohup /user/local/bin/php src.task.php $project >>/var/log/NohupLog/nohup_${project}.log 2>&1 & num = `ps aux | grep -w {project} | grep -v ‘grep‘ |wc -l` if [$num -eq 1] then echo "${log}-已经重启.." >>/var/logs/${log}.log else echo "${log}-失败.." >>/var/logs/${log}.log fi fi
以上是关于linux 脚本--守护进程的主要内容,如果未能解决你的问题,请参考以下文章