PHP code example of renkun-cook / think-cron

1. Go to this page and download the library: Download renkun-cook/think-cron library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

renkun-cook / think-cron example snippets


项目根目录/config/crontab.php


return [
    'tasks' => [
        [
            'time' => '0 10,50 */3 * * *',
            'mode' => [
                'command' => ['test', 'think-queue-manage:handle'],
                'callback' => [
                    ["app\admin\controller\JobTest:test1"],
                    [['app\admin\controller\JobTest','test1']], 
                    ["app\admin\controller\JobTest:test1", 'renkun-cook,renkun-cook2'],
                    ["app\admin\controller\JobTest:test1", ['renkun-cook,renkun-cook2']], 
                    [['app\admin\controller\JobTest','test1'], ['renkun-cook,renkun-cook2']] 
                ]
            ]
        ],
        [
            'time' => '* * * * * *',
            'mode' => [
                'command' => ['think-queue-manage:handle']
            ]
        ],
        [
            'time' => '0 2,9,36 */2 * * *',
            'mode' => [
                'callback' => [
                    ["app\admin\controller\JobTest:test1", 'renkun-cook']
                ]
            ]
        ],
    ]
];