解决小问题: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.配置任务计划程序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值