Monday, February 21, 2022

[SOLVED] Laravel Scheduler not working in Dreamhost VPS

Issue

enter image <a name='more'></a>description here

Laravel scheduler doesn't work in Dreamhost VPS.

Dreamhost has a limitation of not allowing every minute calls so I am doing it in a 10 minute call instead. However, the scheduler doesn't fire in any case.

I have tried the following cron commands:

php ~/site.com/artisan schedule:run >> /dev/null 2>&1

and

cd / site.com && php artisan schedule:run >> /dev/null 2>&1

But both do not work.

Here's what I have inside my kernel.php

protected $commands = [
    'App\Console\Commands\DailyStatus',
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{

    $schedule->command('status:daily')
        ->timezone('Asia/Manila')
        ->dailyAt('6:50');

    $schedule->command('status:daily')
        ->timezone('Asia/Manila')
        ->daily()
        ->between('12:00','12:30')
        ->appendOutputTo(public_path().'status_daily_output.log')
        ->withoutOverlapping(60);

    $schedule->command('status:daily')
        ->timezone('Asia/Manila')
        ->dailyAt('12:15')
        ->appendOutputTo(public_path().'status_daily_at_output.log')
        ->withoutOverlapping(60);
}

The logs are also not being generated. I have put some echo commands and its not firing.

How can I test if my scheduler is properly configured?

Can someone help me fix my current setting?

Thank you.


Solution

So I managed to get this to work after a number of testing.

  1. Make sure that your account can execute the command

     crontab -e
    

    If you can't, contact Dreamhost support to have the permissions fixed.

  2. For your cron command, you need to specify the exact location of your php

    cd ~/site.com  && /usr/local/php72/bin/php artisan schedule:run >> /dev/null 2>&1
    
  3. Since everyminute is not allowed by Dreamhost, I suggest executing it at every 10 minutes instead.

I hope this helps!



Answered By - gjg2013
Answer Checked By - Senaida (WPSolving Volunteer)