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

Lugi's avatar
Level 21

Running scheduled jobs with absolute path to artisan

I had a problem to run cron jobs on shared hosting so I spend some time to troubleshoot and finally came with this in crontab:

/opt/cpanel/ea-php71/root/usr/bin/php /home/userxyz/laravelproject/artisan schedule:run >>/home/userxyz/laravelproject/storage/logs/cron.log

As you could see, I forwarded the output to the log file so I see what is going on. And this is the output:

No scheduled commands are ready to run.
Running scheduled command: '/opt/cpanel/ea-php71/root/usr/bin/php' 'artisan' mycommand:do > '/dev/null' 2>&1
No scheduled commands are ready to run.

So, from this output it is visible that the problem is obviously 'artisan'.

Is there a way to instruct the Laravel to use /home/userxyz/laravelproject/artisan while running the scheduled job ?

P.S. I'm not a root user on this server...

0 likes
1 reply
Lugi's avatar
Lugi
OP
Best Answer
Level 21

The solution was to use exec() instead of command():

$schedule->exec("'/opt/cpanel/ea-php71/root/usr/bin/php' '/home/userxyz/laravelproject/artisan' mycommand:do")->everyFifteenMinutes();

Please or to participate in this conversation.