最近优化了在线考试系统,使用了消息队列,在php命令模式下操作就需要保证mq消费者保持在线.于是就有了shell守护进程的要求。新shell脚本mq.sh#!/bin/shprocnum=`ps -ef|grep "consumer"|grep -v grep|wc -l`if [ $procnum -eq 0 ]; then nohup /usr/bin/php /xxxxx/wwwroot/yii examination/consumer > /tmp.log 2>&1 &fi添加执行权限:chmod +x mq.sh然后在定时任务时添加*/1 * * * * /home/ubuntu/mq.sh经过生产环境使用两天没有问题。...