解决小问题:ThinkPHP 定时任务

编程入门 行业动态 更新时间:2024-10-24 03:26:50

解决小问题:<a href=https://www.elefans.com/category/jswz/34/1766891.html style=ThinkPHP 定时任务"/>

解决小问题:ThinkPHP 定时任务

需求场景:

       TP5 需要定时统计数据,部署目标为云虚拟主机,没有宝塔环境。

       解决思路:用离线电脑访问在线接口,配合Linux Shell /Windows 计划任务 配置定时任务;

一、Windows 

1.搭建好TP5环境

   省略

2.创建Command

namespace app\index\command;use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Log;class Task extends Command
{protected function configure(){$this->setName('Task')->setDescription("测试");}protected function execute(Input $input, Output $output){Log::write('  hello Task','error');}}

3.配置app/command.php

return ['app\index\command\Task'
];

4.编写phptask.bat

E:
cd \code-action\php-action\fast02
D:\phpstudy_pro\Extensions\php\php7.1.9nts\php.exe think Task

5.配置任务计划程序

根据自己任务需求设定时间周期

选择bat执行文件

6.查看日志

runtime/log/2021[月份] / 日期.log

二。Linux (Centos)

 原理一样 细节待整理

 

 

 

更多推荐

解决小问题:ThinkPHP 定时任务

本文发布于:2024-03-09 14:24:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1725226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ThinkPHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!