定时任务调度

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

posted @ 2019-08-13 18:41  飞翔的贺兰猪  阅读(271)  评论(0编辑  收藏  举报