Linux查看TP6 command定时任务并重启

TP6定时任务设置:

1、在项目根目录/app/command 目录下创建定时任务类文件MemberSubmit.php

       使用 $this->setName('memberSubmit')  方法设置名称为 memberSubmit 的定时任务。

namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Exception;

class MemberSubmit extends Command
{
    public $log_path;

    protected function configure()
    {
        // 指令配置
        $this->setName('memberSubmit')
            ->setDescription('解压用户提交资料');
    }

    protected function execute(Input $input, Output $output)
    {
        //此处为定时任务程序代码  任务逻辑
        $output->writeln('MemberSubmit task executed!');
        
    }
}

Linux下查看定时任务:

ps -ef|grep Submit

ps aux|grep memberSubmit

执行以上命令,查询linux下含有“Submit”字符的进程。如列出memberSubmit信息,则说明此定时任务进程存在。如下所示:

[root@test myweb]# ps -ef|grep Submit
root     10515 10513  0 13:08 ?        00:00:00 php think memberSubmit
root     18789 18724  0 15:18 pts/3    00:00:00 grep --color=auto Submit
[root@test myweb]# ps aux|grep memberSubmit
root     10515  0.0  0.3 305076 13660 ?        S    13:08   0:00 php think memberSubmit
root     18949  0.0  0.0 112832   992 pts/3    S+   15:21   0:00 grep --color=auto memberSubmit

其中 10515 为 memberSubmit 定时任务的pid号。

如要重启进程,可执行以下命令:

kill -9 10515

php think memberSubmit

先杀掉旧的进程pid,再执行php think memberSubmit命令重启进程。

你可能感兴趣的:(linux,运维,服务器,定时任务)