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

nnnayeem's avatar

laravel schedule:run is not working on server(via cron jobs)

Hello everyone, I am trying to run schedule run command on server via cron job. I used following command

usr/local/bin/php /home/nemanu/root1/artisan schedule:run >> /dev/null 2>&1 

It worked previously but after changing the hosting it is not working.

Note:my public files are in public_html folder and rest of them are in /home/nemanu/root1

Thanks in advance.

0 likes
9 replies
Talinon's avatar

What doesn't work? The actual artisan command, or cron not executing the command? If the latter, make sure you're using the proper crontab syntax. You need to specify the frequency using the first 5 parameters.

To have it run every minute (pretty common practice I'd think), you would want this for your crontab entry:

* * * * * /usr/local/bin/php /home/nemanu/root1/artisan schedule:run >> /dev/null 2>&1 

Also, make sure that the php executable actually exists within /usr/local/bin Usually, it resides within /usr/bin/

You can try using the which command to locate where your executable is: $ which php

nnnayeem's avatar

Yes I have set up the frequency in cpanel. As I am using shared hosting how do I check php executable?

When I run schedule run command from cotroller it works fine. But in cronjobs does not work. I gave the following command to see log file but file is empty:

/usr/local/bin/php /home/nemanu/root1/artisan schedule:run 1>> /home/nemanu/public_html/log_laravel 2>&1

Note:Before changing the hosting I was able to change the root but now I cant. If I do shows no specified file error which I could not resolved. So I had to keep public file in public_html folder and rest of them in /root1. I mentioned it thinking if it is related somehow.

nnnayeem's avatar

After a bit of analysis I have found that every time the cron is running it gives me a error in error log:

[15-Feb-2019 03:51:01 UTC] PHP Parse error:  syntax error, unexpected '?' in /home/nemanu/root1/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233

I am using php 7.1

Snapey's avatar

No, the php you are using for the Cron is an older version.

You probably need to ask your hosting provider to tell you where you can find the 7.1 cli version

nnnayeem's avatar
nnnayeem
OP
Best Answer
Level 2

I solved the issue by specifying the php version in the command line:

* * * * * /usr/local/bin/ea-php71 /home/nemanu/root1/artisan schedule:run >> /dev/null 2>&1
4 likes

Please or to participate in this conversation.