crontab 检测 laravel 队列进程是否存活

crontab 检测 laravel 队列进程是否存活

脚本代码

#!/bin/bash
count=ps -fe | grep 'artisan queue' |grep -v 'grep' | wc -l
if [ $count -lt 1 ]; then
php /www/wwwroot/bi.xxx.com/artisan queue:work --tries=2 >> queue.log 2>&1 &
fi
exit 0

定时脚本

crontab -e

测试是否生效

查看是否存在
ps -ef | grep 'artisan queue' |grep -v 'grep' | wc -l
关闭进程
ps -ef |grep queue | awk '{print $2}' |xargs kill

猜你喜欢

转载自blog.csdn.net/weixin_38447055/article/details/82805775