2016-03-17 78 views
4

我每隔一小时三种排定作业Kernel.php象下面这样:安排工作

$schedule->command('get:twitter')->cron('* 1 * * * *'); 
$schedule->command('get:facebook')->cron('* 1 * * * *'); 
$schedule->command('get:googleplus')->cron('* 1 * * * *'); 

我想在一定的时间间隔运行这三个时间表如下图所示:

$schedule->command('get:twitter')->cron('* 1 * * * *');//after 1 hour 
$schedule->command('get:facebook')->cron('30 1 * * * *');//after 1.30 hour 
$schedule->command('get:googleplus')->cron('45 1 * * * *');//after 1.45 hour 

这是可能的laravel 5.1

+0

你需要每隔一小时或一天运行一次吗? –

+0

他们已经运行了每个小时......但我想让时间间隔如下:第一个时间表每隔1小时运行一次,第二个每1.5小时运行一次,第三次每1.45小时运行... –

回答

5

没有任何开箱,但你可以做这样的事情:

// every hour 
$schedule->command('get:twitter')->hourly(); 

// every one and a half hours 
$schedule->command('get:facebook')->cron('0 0,3,6,9,12,15,18,21 * * * *'); 
$schedule->command('get:facebook')->cron('30 1,4,7,10,13,16,19,22 * * * *'); 

// every two hours at x.15 minutes (0.15, 2.15, 4.15 etc) 
$schedule->command('get:googleplus')->cron('15 */2 * * * *'); 
+0

这是真的吗?约1.45分钟? –

+0

我认为一切都会在这里工作。你可以创建'每1.45',但它会是非常长和丑陋的代码。 ) –

+0

好的非常感谢你..现在我将添加这在我的kernel.php –