yii2-scheduling 计划组件 [ 2.0 版本 ]
计划任务
$schedule->command('crawling/custom-note')->cron('0 9-22/3 * * * *');
如果服务器有这个进程就不再执行计划任务,有封装过类似方法吗
共 2 个回答
-
摘自 https://github.com/omnilight/yii2-scheduling
Preventing Task Overlaps
$schedule->command('foo')->withoutOverlapping();
Used by default
yii\mutex\FileMutex
or 'mutex' application component (http://www.yiiframework.com/doc-2.0/yii-mutex-mutex.html) -
为啥不结合shell ?想开几个就几个 默认就一个
#!/bin/bash if [ ! $1 ]; then echo "缺少执行任务动作方法" exit 2 fi PHP_EXE="/usr/bin/php" PROJECT_DIR="/www/abc" TASK=${2:-1} ALIVE=`ps -ef | grep $1 | grep -v grep | grep -v /bin/bash | wc -l` if [ $ALIVE -lt $TASK ]; then $PHP_EXE $PROJECT_DIR/yii $1 > /dev/null 2>&1 fi
lizhixiong
注册时间:2016-05-16
最后登录:2020-08-07
在线时长:1小时51分
最后登录:2020-08-07
在线时长:1小时51分
- 粉丝0
- 金钱0
- 威望0
- 积分10