zoukankan      html  css  js  c++  java
  • laravel5.2总结--任务调度

    你可以通过 command() 来调用 artisan 命令, call 来调用方法或函数, 或者 terminal() 来执行单行命令脚本:
     
    1.在app/Console/Commands文件夹下生成php文件
    php artisan make:console Refresh
     
    修改名字 protected $signature = 'refresh';
    修改描述 protected $description = '定时任务';
    写入操作方法
    public function handle()
    {
    //写你要运行的方法
    }
     
    2.在app/Console文件夹下的Kernel.php 文件中注册
    protected $commands = [
    CommandsInspire::class,
    CommandsRefreshToken::class,
    ];
     
    protected function schedule(Schedule $schedule)
    {
    $schedule->command('inspire')
    ->hourly();
    $schedule->command('refresh')
    ->everyMinute();
    }
     
    3、一个需要加入到服务器的 Cron 项目,创建cron.txt文件,里面写的内容(/path/to/artisan替换成你自己的地址)
     
    * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
     
     
    4、终端中用命令开启任务
     
    在终端中项目目录下(Linux 环境)
     
    告诉crontab 文件名: 
    crontab cron.txt
     
    开始定时任务
    crontab -l
     
    或许之后你要结束任务 
    crontab -r
  • 相关阅读:
    c&c++中的宏
    cmake教程
    什么是Grunt
    npm-install camo
    在node.js中建立你的第一个HTTp服务器
    highChart数据动态更新
    css:before和after中的content属性
    清除float浮动三种方式
    中文标准web字体
    网站桌面端和手机端不同url的设置
  • 原文地址:https://www.cnblogs.com/redirect/p/7457034.html
Copyright © 2011-2022 走看看