What do you have in kernel.php ?
I'm trying to run 'php artisan schedule:run' with cronjob but it returns artisan list?
I'm trying to run 'php artisan schedule:run' with cronjob but it returns artisan list?
the command am trying to run with cron: /5*** cd /home/earleffv/myapp-laravel1 && php artisan schedule:run >> /dev/null 2>&1
protected $commands = [
Commands\ExampleCommand::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('example:command')->everyTwoMinutes();
}
Can you show this example:command command ?
Your crontab looks incorrect. It needs 5 "star" attributes: for minute, hour, day of month, month, day of week - separated by at least 1 space. Example taken from Laravel documentation for Task Scheduling:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
This cronjob runs every minute.
If you want cron to run your command for instance every 5 minutes, it should look like this:
*/5 * * * * cd /home/earleffv/myapp-laravel1 && php artisan schedule:run >> /dev/null 2>&1
Various version can be tried here: https://crontab.guru/
Yeah it has spaces between them, i just typed it incorrectly here
Nevertheless, it's emailing the output as artisan list as if i typed 'php artisan' or 'php artisan list' at the terminal
it's freaking frustrating
a useful info: am trying to run it at a shared hosting, the shared hosting allows cron jobs
try adding register_argc_argv = On to your php.ini
it solved it for me, without it cron did not pass the schedule:run as an argument and run only the php artisan part
Hi @v2n , I did solve it but I forgot how, I think the problem was because I was testing on shared hosting... when I moved the project to the actual server it worked
And it's just my curiosity , but how did you end up with the same issue?
@V2n This solved my problem. Thanks! 🤩
How is it 'emailing out'
Please paste the actual cron details, not your recollection of them
I fixed this by specifying the path to PHP instead of using just php.
cd /home/path_to_website && /usr/local/bin/php artisan schedule:run
@Yorhmzy THIS ONE DID MAGIC! Thanks Yorhmzy! God bless you in Christ Jesus!
Hi all,
If you are using cPanel and multiple PHP versions on your server, you can target what version will be used to execute artisan command. This is something I had on my hosting provider.
Here is how to target PHP 8.2 which works for Laravel 10.x
* * * * * cd /home/myaccountname/mydomain.com && /opt/cpanel/ea-php82/root/usr/bin/php artisan schedule:run >/dev/null 2>&1
Using /usr/local/bin/php OR /usr/bin/php it will target default PHP version, but this could be PHP 8.0 or lower and it would not work.
Please or to participate in this conversation.