[英]laravel task scheduler
I want to know if the task scheduler of laravel forge override the settings in my Kernel Class file because I don't understand which one it will use because I set in the dashboard of laravel forge daily and in my kernel class file a command to run only it's the first of the month like this 我想知道laravel forge的任务调度程序是否覆盖了我的内核类文件中的设置,因为我不知道它将使用哪一个设置,因为我每天在laravel forge的仪表板中设置,并且在我的内核类文件中设置了要运行的命令只是这样的一个月的第一天
$schedule->command('log:demo')->daily()->when(function(){
if(Carbon::now()->toDateString() == Carbon::now()->startOfMonth()->toDateString())
{
return true;
}
});
I put daily() function here to check everyday if it's the first of the month and I know that it will not be executed if the function doesn't return true but with laravel forge it's executed everyday , I think forge doesn't look at this file 我在这里放置了daily()函数,每天检查它是否在每月的第一天,如果函数没有返回true,但是我知道它不会被执行,但是使用laravel forge每天都会执行,我认为伪造不会这个文件
You want the schedule:run to run EVERY MINUTE - this checks what you have in your Kernel and if something needs to be ran on that minute it will run that particular task (job). 您希望schedule:run每隔一分钟运行一次-这将检查您的内核中是否有内容,如果需要在该分钟内运行某些内容,它将运行该特定任务(作业)。
For example if I have a task that runs once per/hour and another that runs once per day. 例如,如果我有一个任务,每小时运行一次,而另一个任务每天运行一次。 I would only need ONE scheduled task in Forge: schedule:run - THEN in my Kernel I would have
我在Forge中只需要一个预定的任务:schedule:run-然后在我的内核中
protected function schedule(Schedule $schedule)
{
$schedule->command('report:hourly')->hourly();
$schedule->command('report:daily')->daily();
}
Make sure that your commands are registered with the Kernel: 确保您的命令已在内核中注册:
protected $commands = [
Commands\Hourly::class,
Commands\Daily::class,
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.