定时任务调度

1、在服务器中新增cron入口
crontab -e

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

 

2、任务执行主体定义在app/Console/Commands 里
artisan命令创建Test.php文件

php artisan make:command Test

定时任务调度

 

3、在 App\Console\Kernel 类的 schedule 方法中定义所有的调度任务

定时任务调度

 

定时任务调度

 


手动运行一次检查是否异常
php artisan schedule:run //运行定时任务

详细见文档 https://learnku.com/docs/laravel/5.8/scheduling/3924

上一篇:动态定时任务


下一篇:如何在java中的特定时间和星期几“制造东西”?