doulu1914 2019-05-19 15:18
浏览 380

将Laravel迁移到另一台服务器

I have a problem with migrating laravel to another server, I currently have laravel + redis of which I have some functions in the site cache on redis, the problem is the following, the site works in the other server, but the command schedule:run does not work in cronjob, I tried to run it manually, but it gives me back "No scheduled commands are ready to run" when on the first server runs correctly, the second server is ubuntu 16.04, there is something special to do when changing server? attached I enclose the kernel.php

The old server has Centos 7 Running MariaDB 10.1, PHP 7.2 and NGINX
The new has Ubuntu 16.04 Running MariaDB 10.1, PHP 7.2 and NGINX


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 = [
        '\App\Console\Commands\CacheSideBar',
        '\App\Console\Commands\DailyReset',
        '\App\Console\Commands\WeeklyReset',
        '\App\Console\Commands\MonthlyReset',
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
         //$schedule->command('cache:sidebar');
        $schedule->command('reset:daily')
                 ->daily()
                 ->withoutOverlapping();

        $schedule->command('reset:weekly')
                 ->weeklyOn(1, '00:00')
                 ->withoutOverlapping();                 

        $schedule->command('reset:monthly')
                 ->monthlyOn(1, '00:00')
                 ->withoutOverlapping();

        $schedule->command('cache:sidebar')
                 ->everyTenMinutes()
                 ->withoutOverlapping();


    }

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

        require base_path('routes/console.php');
    }
}
  • 写回答

1条回答 默认 最新

  • dqwmhrxt68679 2019-05-19 16:39
    关注

    Assuming you already have crontab installed on the server. You need to register the your cronjobs using crontab on the server.

    N.B if you don't have it installed see https://tecadmin.net/install-crontab-in-linux/ or https://www.rosehosting.com/blog/linux-crontab/

    steps:

    1) ssh into the server

    2) type crontab -e in the cli

    3) add the cronjobs by typing * * * * * cd /var/www/yoursite && php artisan schedule:run . then save.

    4) Now the php artisan schedule:run will be run every minute, checking if there is any due commands to run.

    N.B for you to run it manually, try changing the 'daily' to 'everyMinute' like so:

    $schedule->command('reset:daily')
                     ->everyMinute()
                     ->withoutOverlapping();
    

    It will get triggered. Hope it helps :)

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog