有没有办法延迟或偏移计划中的命令,以符合提供的频率选项?
例如:
$schedule->command('GetX')->everyTenMinutes(); --> run at 9:10, 9:20, 9:30
$schedule->command('GetY')->everyTenMinutes(); --> run at 9:15, 9:25, 9:35
有没有办法延迟或偏移计划中的命令,以符合提供的频率选项?
例如:
$schedule->command('GetX')->everyTenMinutes(); --> run at 9:10, 9:20, 9:30
$schedule->command('GetY')->everyTenMinutes(); --> run at 9:15, 9:25, 9:35
// this command is scheduled to run if minute is 05, 15, 25, 35, 45, 55
// the truth test is checked every minute
$schedule->command('foo:bar')->everyMinute()->when(function () {
return date('i') - 5 % 10 == 0;
});
$schedule->command('foo:bar')->everyMinute()->when(function () {
return date('i') - y % x == 0;
});
$schedule->command('foo:bar')->cron('05,15,25,35,45,55 * * * *');
date('m')
应该改成date('i')
。我把date('m') - y % x == 0
改成了substr(date('i'), -1) == 0
和substr(date('i'), -1) == 5
,因为这样更容易理解。 - undefinedreturn (date('m') - 5) % 10 == 0;
。 - undefined