krisko24

Registered
Oct 22, 2017
4
0
1
United states
cPanel Access Level
Root Administrator
I cant seem to get CLI to get recognized during my cron jobs. I can get it to return just fine when I run the script from the terminal. Im using php_sapi_name() to return CLI.

here is my cron script.

* * * * * /usr/bin/ea-php71 /home/coin/public_html/cron/price_alerts.php >/dev/null 2>&1

I've also tried

* * * * * /usr/bin/php /home/coin/public_html/cron/price_alerts.php >/dev/null 2>&1

* * * * * php /home/coin/public_html/cron/price_alerts.php >/dev/null 2>&1


It was kind of bazaar but I had my cron jobs work a couple times and it returned CLI but most the time my cron jobs just return cgi-fcgi
 

24x7server

Well-Known Member
Apr 17, 2013
1,913
99
78
India
cPanel Access Level
Root Administrator
Twitter
Hi,

Try below PHP executable path instead of what you are giving in it..
# /opt/cpanel/ea-php71/root/usr/bin/php

Also, execute below command to see if there is any error:

# /opt/cpanel/ea-php71/root/usr/bin/php /home/coin/public_html/cron/price_alerts.php
 

krisko24

Registered
Oct 22, 2017
4
0
1
United states
cPanel Access Level
Root Administrator
So this worked! /opt/cpanel/ea-php71/root/usr/bin/php . But now my file paths for my includes are messed up.

PHP Fatal error: require(): Failed opening required '../vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/coin/public_html/cron/price_alerts.php
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
Hello,

You should use one of the following commands for PHP with your cron jobs:

General example:

Code:
/usr/local/bin/php /home/$user/public_html/path/to/cron/script
Domain-specific example:

Code:
/usr/local/bin/ea-php56 /home/$user/domain_path/path/to/cron/script
In the above example, replace “ea-php56” with the PHP version assigned to the domain you wish to use. Look in the MultiPHP Manager for the actual PHP version assigned to a domain.

Thank you.
 

krisko24

Registered
Oct 22, 2017
4
0
1
United states
cPanel Access Level
Root Administrator
Yes if I /usr/local/bin/ea-php71 then my cron script won't recognize CLI. The only way I can get it to recognize CLI is by using /opt/cpanel/ea-php71/root/usr/bin/php. But now my includes paths are messed up.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
Yes if I /usr/local/bin/ea-php71 then my cron script won't recognize CLI. The only way I can get it to recognize CLI is by using /opt/cpanel/ea-php71/root/usr/bin/php. But now my includes paths are messed up.
Feel free to open a support ticket using the link in my signature if you'd like us to take a closer look.

Thank you.