Skip to content
Menu
小小述博客
  • 首页
  • Nginx
  • Php
  • Laravel
  • Git
  • 在线工具
  • 资源下载
  • Magento2
小小述博客
2022年5月13日

Laravel 5 Kernel 添加定时任务操作

Post Views: 163

在前一章内容,我们已经做了定时任务的功能。我们现在需要把定时任务操作条件到 Kernel。

添加方法:将操作名称添加到 command()里面,然后后边跟上定时任务规则。

 protected function schedule(Schedule $schedule)
    {
        $schedule->command('merchant-order:sync')->everyMinute();
    }

完整的代码如下:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('merchant-order:sync')->everyMinute();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

然后在服务器上添加下面定时任务代码

* * * * * cd /home/laravel && php artisan schedule:run >> /dev/null 2>&1

504 API Bootstrap基础 Composer 基础 Docker elasticsearch facebook Git 基础 Google Go 入门 IntegerNet_Solr jdk Jquery Laravel Laravel-admin Laravel 入门到精通教程 Laravel 基础 Linux Cron Linux sudo linux命令 Linux权限 Linux 用户和组 Linux 解压 Lnmp Magento2 主题 Magento2 事件 Magento2 功能 Magento2 命令 Magento2 安装 Magento2 数据库 Magento2 模块 Mamp Paypal php Phpstorm PHP优化 PHP函数 Php面试题 Robots solr Sourcetree SSH SSL Wordpress 阿里云服务器

  • Magento2 Magento\Framework\Exception\InputException): An ID is needed. Set the ID and try again.2023年4月12日
  • Magento2  社区版本怎么获取没有下单的弃购用户的邮箱和加购产品的信息2023年4月9日
  • linux 系统查看所有用户的crontab定时任务2023年1月5日
  • Mgento 2 缓存文件用户组权限不对2023年1月5日
  • Magento 2 中怎么禁用事件观察器2022年12月30日
  • Elasticsearch 安装与卸载2022年12月2日
  • Magento 2.4 Content security policies 内容安全策略2022年11月2日
  • Magento 2.4 Disable Page Builder2022年11月1日
  • phpMyAdmin无法缓存模板文件,所以会运行缓慢2022年10月29日
  • PhpMyAdmin配置文件现在需要一个短语密码2022年10月29日
  • 开源工厂
  • 码农网
  • 前端学习
  • Get社区学习
  • Guru99 学习
  • tecadmin.net
  • 深入理解PHP内核
  • 国际IT专场
  • 51CTO
  • https://bbs.mallol.cn
  • http://techjeffyu.com/
  • https://webkul.com/
  • qastack
  • Innfoq
  • 刘祥博客
  • 阿里云
  • DigitalOcean
  • 华为云服务器
  • 华为云开发者中心
  • 华为云服务器文档
  • 阿里云服务器文档
  • Linux命令大全(手册)
  • WEB技术分享
  • 博学无忧博客
  • Ostechnix
  • Linux公社
  • LinuxHomene
  • Linux 服务器操作
  • Linux 就该这么学
  • Linux 从入门到精通
  • Linux 中国开源社区
  • Linux命令大全(手册)
  • Ubuntu Apache 命令学习
  • CSDN
  • 菜鸟学习教程
  • 鸟哥的Linux 私房菜
  • w3school教程
  • Bootstrap 中文网
  • Yii 中文网
  • Yii中文框架
  • 程序员的在线工具
  • 运维教程
  • 梦康的博客
  • 考评师
  • 社交分享教程
  • GitHub
  • 后端进阶
  • 端隐SDP 零信任安全
  • 示说网
  • 脚本之家
  • 开源资源
  • 蓝文资源库
  • Ubuntu 官网
  • linuxize.com
  • Linux Help
  • tecmint
  • 脚本之家在线工具
  • php1中文社区
  • 云知梦
  • IT之家
  • https://www.geeksforgeeks.org/
  • https://laravel-school.com/
  • https://laravelacademy.org/
  • https://zditect.com/guide/
  • https://www.studytonight.com/
  • https://dev.to/
  • https://dev.to/listings
  • https://dev.to/saifullah/8-free-websites-to-learn-coding-3c5
  • https://www.rakeshjesadiya.com/
  • magento-2-video-tutorials

©2023 小小述博客 | Powered by WordPress and Superb Themes!