Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AegisOrta's avatar

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

0 likes
12 replies
Snapey's avatar

What do you have in kernel.php ?

AegisOrta's avatar
protected $commands = [
        
        Commands\ExampleCommand::class,

 ];

    protected function schedule(Schedule $schedule)
    {


        $schedule->command('example:command')->everyTwoMinutes();

   }
Sinnbeck's avatar

Can you show this example:command command ?

kmatan's avatar

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/

AegisOrta's avatar

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

vitnasinec's avatar

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

2 likes
AegisOrta's avatar

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?

Snapey's avatar

How is it 'emailing out'

Please paste the actual cron details, not your recollection of them

Yorhmzy's avatar

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

2 likes
markomo's avatar

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.

1 like

Please or to participate in this conversation.