{"id":1138,"date":"2022-05-11T16:47:53","date_gmt":"2022-05-11T08:47:53","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1138"},"modified":"2022-06-24T10:20:16","modified_gmt":"2022-06-24T02:20:16","slug":"php-process-daemon-script","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2022\/05\/php-process-daemon-script\/","title":{"rendered":"PHP \u8fdb\u7a0b\u5b88\u62a4\u811a\u672c"},"content":{"rendered":"
#!\/bin\/bash\nPRO_NAME=test\ncd \/home\/wwwroot\/default\nwhile true ; do\n #\u7528ps\u83b7\u53d6$PRO_NAME\u8fdb\u7a0b\u6570\u91cf\n NUM=`ps aux | grep -w "\/usr\/bin\/php think ${PRO_NAME}" | grep -v grep |wc -l`\n #echo $NUM\n #\u5c11\u4e8e1\uff0c\u91cd\u542f\u8fdb\u7a0b\n if [ "${NUM}" -lt "1" ];then\n echo "${PRO_NAME} was killed"\n nohup \/usr\/bin\/php think ${PRO_NAME} >> ${PRO_NAME}.log 2>&1 &\n #\u5927\u4e8e1\uff0c\u6740\u6389\u6240\u6709\u8fdb\u7a0b\uff0c\u91cd\u542f\n elif [ "${NUM}" -gt "1" ];then\n echo "more than 1 ${PRO_NAME},killall ${PRO_NAME}"\n ps aux | grep -w ${PRO_NAME} | grep -v grep |grep -v ${PRO_NAME}_deamon.sh |awk '{print $2}' |xargs kill -9\n nohup \/usr\/bin\/php think ${PRO_NAME} >> ${PRO_NAME}.log 2>&1 &\n fi\n sleep 5s\ndone\n\nexit 0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"#!\/bin\/bash PRO_NAME=test cd \/home\/wwwroot\/default whil<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,14],"tags":[110,29],"yoast_head":"\n
PHP \u8fdb\u7a0b\u5b88\u62a4\u811a\u672c - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n