Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CLI not recognized in cron jobs

Discussion in 'EasyApache' started by krisko24, Oct 22, 2017.

  1. krisko24

    krisko24 Registered

    Joined:
    Oct 22, 2017
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,675
    Likes Received:
    73
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    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
     
  3. krisko24

    krisko24 Registered

    Joined:
    Oct 22, 2017
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    41,502
    Likes Received:
    1,616
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  5. krisko24

    krisko24 Registered

    Joined:
    Oct 22, 2017
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    41,502
    Likes Received:
    1,616
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page