【发布时间】:2020-10-22 01:41:43
【问题描述】:
我有一些计划用于在某些时间清理数据库,但我想使用 cron 来运行这些时间,但是当我尝试在 Windows 计划中运行它们时,我收到以下错误:
6 is not a valid position
at C:\laragon\www\Sis\vendor\dragonmantank\cron-expression\src\Cron\FieldFactory.php:46
42| case 4:
43| $this->fields[$position] = new DayOfWeekField();
44| break;
45| default:
> 46| throw new InvalidArgumentException(
47| ($position + 1) . ' is not a valid position'
48| );
49| }
50| }
1 C:\laragon\www\Sis\vendor\dragonmantank\cron-expression\src\Cron\CronExpression.php:154
Cron\FieldFactory::getField()
2 C:\laragon\www\Sis\vendor\dragonmantank\cron-expression\src\Cron\CronExpression.php:137
Cron\CronExpression::setPart("*")
而且我对 crons 没有太多经验,据我所知,它应该需要 6 个星号,并且您指定了分钟、小时、天、月,我该如何解决?
这是代码:
protected function schedule(Schedule $schedule)
{
$schedule->command('S:LA')->cron('0 23 4 1 * *');
$schedule->command('S:LC')->cron('0 23 4 2 * *');
$schedule->command('S:LC')->cron('0 23 4 6 * *');
$schedule->command('S:LC')->cron('0 23 4 10 * *');
$schedule->command('S:LD')->dailyAt('00:00');
$schedule->command('S:LM')->monthlyOn(4, '23:00');
$schedule->command('S:LS')->mondays()->at('23:00');
$schedule->command('S:LSM')->cron('0 23 4 6 * *');
$schedule->command('S:LSM')->cron('0 23 4 1 * *');
$schedule->command('S:LT')->cron('0 23 4 1 * *');
$schedule->command('S:LT')->cron('0 23 4 3 * *');
$schedule->command('S:LT')->cron('0 23 4 6 * *');
$schedule->command('S:LT')->cron('0 23 4 9 * *');
$schedule->command('S:LT')->cron('0 23 4 12 * *');
}
【问题讨论】:
标签: laravel cron scheduled-tasks