skip to Main Content

I am trying to setup a Cron job which will run after every minute and perform some task. I am using Laravel 5.5 and my site is hosted on Godaddy with shared hosting plan.
First I have implemented schedule method in app/Console/Kernel.php file like below:

    protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        $video = new Video;
        $video->title = 'sample title';
        $video->save();
    })->everyMinute();
}

Then I have created a Cron Job in relevant section from Godaddy cPanel section. This section looks like below:

enter image description here

I have also setup to send me email every time this tasks runs but nothing is happening. No email, no new entry in Videos table. Although other parts of application are configured correctly and working fine.
As far as my guess is, there seems to be something wrong with the path to artisan file that is given in php command. I have tried different combinations but no luck.

2

Answers


  1. Chosen as BEST ANSWER

    I have fixed the issue. The problem was in the command. Firstly I had to put ~ at the start of the path to artisan file. Second I had to enter the absolute path to the php executable. So the final command that worked for me is:

    /usr/local/bin/php ~/public_html/fifa/artisan schedule:run >> /dev/null 2>&1
    

  2. I am using Laravel Forge and this works for me:

    php /home/forge/project_directory/artisan schedule:run
    

    Is /public_html/fifa the path to your project? Try running artisan directly from your project directory:

    php /path_to_project/artisan schedule:run
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search