2
votes

I am running my web app under godaddy shared hosting, and I am trying to run a cron job which will call my schedule task in my laravel app. For some reason the scheduler is not being called. These are the commands in godaddy that I have tried so far:

          • php /path/to/artisan schedule:run >> /dev/null 2>&1
          • home/lulzimf/php /home/path/to/artisan schedule:run 1>> /dev/null 2>&1
          • usr/local/php /home/path/to/artisan schedule:run 1>> /dev/null 2>&1
          • /usr/local/bin /path/to/artisan schedule:run >> /dev/null 2>&1

None of these above commands seems to execute my task scheduler, I have tried calling the command from using artisan command, it works... What do you think this is not working?

This is how my Kernel looks like:

<?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 = [
        'App\Console\Commands\Inspire',
        'App\Console\Commands\UpdateClassSession',
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('inspire')
                 ->hourly();
        $schedule->command('class-session-update')
                 ->everyFiveMinutes();
    }

}
1
I assume you have real path to 'artisan' file in your cron tab, instead of /path/to/artisan?Denis Mysenko
@DenisMysenko how do I check for that?artan
/path/to/artisan - this is just a placeholder. whoever told you to use this, meant that you need to replace this string with your actual path to 'artisan' file. you cannot expect /path/to to be a real folderDenis Mysenko

1 Answers

0
votes

Not just godaddy, in my experience with other hosting I had to edit the Schedule.php file in Illmuniate\Console\Scheduling.

And then I edited Line 49 to this return $this->exec("/usr/bin/php -ea_php 70 -q /home/xxxxx/xxxxx/artisan {$command}", $parameters);

So basically this will run the queue:work command or any other commands with the full path to php and the full path to artisan.

In my case I also had to add -ea_php 70 because the default php version being used by the cli was not supported by laravel.

So:

  1. Check PHP version and make sure it is supported by laravel.
  2. Check PHP version being used by the cli to execute your cron.
  3. Verify and use full path to php.
  4. Verify and use full path to artisan.

In some cases you might also get this error:

undefined index argv

For that you will have to edit your php.ini file and set register_argc_argv to on.