cronPro,其中有一项功能为强杀任务;这里也可以借助shell
命令来完成,通过shell
脚本获取任务的pid
,这样就可以通过脚本来控制程序在操作系统层面上一定会被kill
。
取自falcon-plus的启动脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function check_pid() { if [ -f $pidfile ];then pid=`cat $pidfile` if [ -n $pid ]; then running=`ps -p $pid|grep -v "PID TTY" |wc -l` return $running fi fi return 0 }
function start() { check_pid running=$? if [ $running -gt 0 ];then echo -n "$app now is running already, pid=" cat $pidfile return 1 fi
nohup ./$app &> $logfile & echo $! > $pidfile echo "$app started..., pid=$!" }
function stop() { pid=`cat $pidfile` kill $pid echo "$app stoped..." }
|
本文标题:分布式定时任务之强杀任务
文章作者:小师
发布时间:2019-05-05
最后更新:2022-04-07
原始链接:chunlife.top/2019/05/05/分布式定时任务之强杀任务/
版权声明:本站所有文章均采用知识共享署名4.0国际许可协议进行许可