zoukankan      html  css  js  c++  java
  • laravel5.5的任务调度(定时任务)详解(demo)

    https://blog.csdn.net/LJFPHP/article/details/80417552

    laravel5.5的定时任务详解(demo) 这篇文章写得挺详细的。看了它我基本就会用了

    php artisan make:command Test  新建任务调度文件

    app/Console/Commands/Test.php

    protected $signature = '<name>'; 定义什么值,就直接在命令行里执行 php artisan <name>
    protected $signature = 'command:Test';   命令执行 php artisan command:Test
    protected $signature = 'command:scr';   命令执行 php artisan command:scr
    //这段代码意思就是在命令行执行时候的名字   php artisan test:data 就可以直接自行此文件了 
    protected
    $signature = 'test:data';

    ( 实际情况  我是修改了  namespace AppConsole; 输入命令 php artisan test:data 才顺利执行了这个文件)
    /**
    这样就相当于直接调用了StaticPagesController 用在了调度任务中
    **/
    use AppHttpControllersStaticPagesController;
    .
    .
    .
        
        public function __construct(StaticPagesController $sp)
        {
            parent::__construct();
            $this->sp = $sp;
        }
    /**
    在 Kernel  任务配置调度文件  
    **/
    
    
    class Kernel extends ConsoleKernel
    {
        protected $commands = [
            test::class,
        ];

    ubantu crontab 命令

    crontab -e 配置计划任务

    crontab -l 查看计划任务

    sudo service cron start 启动计划任务

    sudo service cron restart 重启计划任务

    sudo service cron stop 停止计划任务

    sudo service cron status 查看计划任务状态

    测试计划任务是否执行

    php /home/vagrant/Code/Bi/artisan schedule:run
  • 相关阅读:
    接口测试
    Face Anti-Spoofing人脸活体检测-双目红外活体检测
    Spring面试题目
    1.多线程说在前面的话
    2.三分钟入门多线程
    卷积计算
    springmvc 后台向页面EasyUI的tree传递数据(JSon格式)
    springmvc 后台向页面EasyUI的Datagrid传递数据(JSon格式)
    分页工具 Pagehelper的学习 (Spring+Mybatis)
    一些免费的WebService的服务网站(转发)
  • 原文地址:https://www.cnblogs.com/zhaoyang-1989/p/9670554.html
Copyright © 2011-2022 走看看