thinkphp5在linux系统下实现定时任务
在command下创建Test类文件,继承Command,并重写confugure(setName表示运行的方法名简称,例php think Test)和execute方法,修改command.php,加入cmd要运行的文件路径。
1,切换命令到应用根目录文件夹运行测试
在ticket新建 .sh 文件,写入
cd /www/wwwroot/lottery588.cn/ticket
php think Test
连接服务器 ,使用crontab -e写入 定时表达式。具体查看crontab定时表达式写法
。
。
。
。
。
。
。
。
。
。
。
。
。
。
。
2,切换到网站根目录直接运行控制器-》方法测试
其实这个和第一个差不都,自己摸索。