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:
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
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:
I am using Laravel Forge and this works for me:
Is /public_html/fifa the path to your project? Try running artisan directly from your project directory: