laravel 定时任务 5.2

2018年5月7日 作者 张舫

官方文档给出的教程已经很详细了,这里给出一些补充帮助大家理解。

英文文档:https://laravel.com/docs/5.2/scheduling

中文文档:https://laravel-china.org/docs/5.2/scheduling

 

Starting The Scheduler

这里文档说的很简单,就是让你在服务器的crontab加入一条命令。

关于crontab可以参考这篇文章:http://www.cnblogs.com/xxoome/p/6091459.html

这条命令什么意思呢?按照crontab配置文件格式的解释

红框内都是shell命令。

##如果配有配置php的全局环境变量,这里需要指定php的绝对路径。
php:/usr/local/php/bin/php

##就是你项目根目录下的artisan文件的绝对路径
artisan:/home/prj-test/test/artisan

例如:

1、创建artisan命令行

文档地址:https://laravel-china.org/docs/5.2/artisan

 

2、编写Kernel