Commit 8ae404cb authored by 杨培's avatar 杨培

加入计划任务

parent 6a527b67
......@@ -8,8 +8,8 @@
namespace console\controllers;
use Jobby\Jobby;
use Yii;
use yii\console\Controller;
class TaskController extends Controller
......@@ -17,11 +17,12 @@ class TaskController extends Controller
public function actionIndex()
{
$jobby = new Jobby();
$yiiCommand = $_SERVER['SCRIPT_FILENAME'];
$output = Yii::getAlias('@runtime') . "/logs/jobs-" . date('Y-m-d') . ".log";
if(YII_DEBUG){
$time = date('Y-m-d H:i:s');
$output = \Yii::getAlias('@runtime') . "/logs/jobs-" . date('Y-m-d') . ".log";
$jobby->add('CommandExample', [
// Run a shell commands
'command' => "echo $time",
......@@ -39,6 +40,22 @@ class TaskController extends Controller
]);
}
//minute hour mday month wday [year]
$jobby->add('WithdrawSettle', [
'command' => "$yiiCommand withdraw/settle",
'schedule' => '30 8 * * 1-5', //每周一到周五上午8:30
'output' => $output,
'enabled' => true
]);
$jobby->add('ClearUploadPool', [
'command' => "$yiiCommand maintain/clear-upload-pool",
'schedule' => '15 */2 * * *', //每隔两小时的第15分钟
'output' => $output,
'enabled' => true
]);
$jobby->run();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment