![](/img/trans.png)
[英]How can I run scheduler every one minute in Laravel without setting cron job?
[英]How can I run this cron?
我有一些計划用於在某些時間清理數據庫,但我想使用 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 * *');
}
->cron('* * * * *'); Run the task on a custom Cron schedule
->everyMinute(); Run the task every minute
->everyTwoMinutes(); Run the task every two minutes
->everyThreeMinutes(); Run the task every three minutes
->everyFourMinutes(); Run the task every four minutes
->everyFiveMinutes(); Run the task every five minutes
->everyTenMinutes(); Run the task every ten minutes
->everyFifteenMinutes(); Run the task every fifteen minutes
->everyThirtyMinutes(); Run the task every thirty minutes
->hourly(); Run the task every hour
->hourlyAt(17); Run the task every hour at 17 minutes past the hour
->everyTwoHours(); Run the task every two hours
->everyThreeHours(); Run the task every three hours
->everyFourHours(); Run the task every four hours
->everySixHours(); Run the task every six hours
->daily(); Run the task every day at midnight
->dailyAt('13:00'); Run the task every day at 13:00
->twiceDaily(1, 13); Run the task daily at 1:00 & 13:00
->weekly(); Run the task every sunday at 00:00
->weeklyOn(1, '8:00'); Run the task every week on Monday at 8:00
->monthly(); Run the task on the first day of every month at 00:00
->monthlyOn(4, '15:00'); Run the task every month on the 4th at 15:00
->quarterly(); Run the task on the first day of every quarter at 00:00
->yearly(); Run the task on the first day of every year at 00:00
->timezone('America/New_York'); Set the timezone
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.