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.

EasyApache 4 Cron Issue

Discussion in 'EasyApache' started by Josh Abbott, Mar 12, 2016.

  1. Josh Abbott

    Josh Abbott Member

    Joined:
    Oct 4, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Root Administrator
    After updating a server to EasyApache 4 I noticed that several cron jobs quit working. After some testing, I've determined that PHP scripts running as crons are not properly including files from upper level directories after EasyApache 4 is installed.

    To demonstrate the issue, I created a simple PHP script with two files:

    The first file is public_html/config.php with the following contents:

    <?php
    $dbhost = 'localhost';
    $dbname = 'testsite_database';
    $dbuser = 'testsite_dbuser';
    $dbpass = 'Testing123';

    ?>

    And the second file is public_html/testdir/testfile.php with the contents:

    <?php
    require "../config.php";
    $dblink = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("Unable to connect to database");
    mysqli_query($dblink, "INSERT INTO log (logentry) VALUES ('Successfully ran file at ".date("F j, Y, g:i:s a")."')");

    ?>

    When I open testdir/testfile.php in my browser, the file runs fine with both EasyApache 3 and EasyApache 4.

    I added the file as a cron job with the command:
    /usr/bin/php -f /home/testsite/public_html/testdir/testfile.php

    In EasyApache 3 the file continues working as expected. However, after upgrading to EasyApache 4, the file terminates with a fatal error:

    [12-Mar-2016 22:23:01 UTC] PHP Warning: require(../config.php): failed to open stream: No such file or directory in /home/testsite/public_html/testdir/testfile.php on line 3

    [12-Mar-2016 22:23:01 UTC] PHP Fatal error: require(): Failed opening required '../config.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/testsite/public_html/testdir/testfile.php on line 3


    I've reverted back to EasyApache 3 and reinstalled EasyApache 4 several times, and the results have been consistent. The file always runs fine when I open it in a browser, and it works fine as a cron in EasyApache 3, but it fails to run as a cron in EasyApache 4. The file also works fine as a cron on a different server where CloudLinux is installed. I used PHP 5.6 in each test.

    Another thing I noticed is that when running as a cron in EasyApache 4, the errors are written to the user's home directory /home/testsite/error_log rather than the directory in which the PHP file was executed. I wasn't sure if this was by design, or if it could be related to the issue.
     
  2. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    We're doing some testing internally checking this out right now. I hope to have a little more information on this shortly. Thanks for your report!
     
  3. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    We've replicated this and opened case EA-4337 to get this fixed. Thanks for your report!
     
  4. kirklove

    kirklove Registered

    Joined:
    Mar 23, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Buffalo, NY
    cPanel Access Level:
    Root Administrator
    Has there been any kind of resolve to this yet? I believe I have this same issue or something along this line. I have a very basic cron job and they "cron's" have completely stopped working. Manually, everything is fine. Just want to know if there is a solution or if I should fall back to easyapache 3.

    Thanks!

    Kirk
     
  5. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    As a temporary workaround, you can call the SCL PHP version + -cgi that you want to execute.

    IE: Instead of /usr/bin/php, instead call the interpreter: /opt/cpanel/ea-php##/usr/bin/php-cgi

    We're looking at different solutions right now, and hope to have something out shortly to fix.
     
  6. kirklove

    kirklove Registered

    Joined:
    Mar 23, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Buffalo, NY
    cPanel Access Level:
    Root Administrator
    I think you just threw me into noob town. haha.

    What exactly are we doing here. Are we working inside cpanel under crons? I tried inserting this into the cron line a bunch of ways with no success but I feel like I am doing this wrong.

    Sorry to bother!
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Could you let us know what you entered for the cron job? For instance, did you replace "ea-php##" with the actual PHP version number?

    Thank you.
     
  8. kirklove

    kirklove Registered

    Joined:
    Mar 23, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Buffalo, NY
    cPanel Access Level:
    Root Administrator
    Hey!

    I added the line as /opt/cpanel/ea-php70/usr/bin/php-cgi

    Would this be correct?

    I got this error.

    /bin/sh: /opt/cpanel/ea-php70/usr/bin/php-cgi: No such file or directory

    Thanks!
     
  9. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    Sorry! I didn't put the full path properly, my bad. The full path to that versions php-cgi would be:
    /opt/cpanel/ea-php70/root/usr/bin/php-cgi

    The cron would look something like (as an example):
    * * * * * /opt/cpanel/ea-php70/root/usr/bin/php-cgi /home/perk/public_html/cron.php

    I hope this helps!
     
    kirklove likes this.
  10. kirklove

    kirklove Registered

    Joined:
    Mar 23, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Buffalo, NY
    cPanel Access Level:
    Root Administrator
    Thanks! It worked. Sorry for being a little lost there. It was strange, at first, the cron didn't work. then after the second minute it kicked in and started working. Non the less. Its working. I can get on with things for now. Thanks a ton!
     
  11. Josh Abbott

    Josh Abbott Member

    Joined:
    Oct 4, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Root Administrator
    I'm still experiencing this bug in EA4 after updating to 58.0.3.

    Changing "/usr/bin/php" to "/opt/cpanel/ea-php56/root/usr/bin/php-cgi" in the cron command seems to fix the issue, but that still means that the client's existing cron jobs will stop working after migrating from EA3 to EA4. I don't think EA4 should be released out of BETA until this bug is fixed, since it would affect a large number of clients and also coding the PHP version into the commands will cause further confusion and issues if the clients wish to change to a different version of PHP.

    Since CloudLinux offers multiple PHP versions and the "/usr/bin/php" cron commands work fine on CloudLinux servers, couldn't a similar method of running crons be implemented in EA4?
     
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    A resolution for case EA-4337 has not been published. I'll update this thread as soon as more information on the time frame of the resolution is available.

    Thank you.
     
  13. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    We are planning to get a temporary fix out to get this taken care of while we plan the proper fixes in the background. We have an emergency release tomorrow with PHP updates, however I plan to get a quick fix in ASAP and get it public. I'll update this thread once we get it into our development branches.

    Thanks for our patience!
     
  14. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    I have a fix in testing, and I was wondering if anyone would be interested in testing this out on their system. It's just a simple RPM upgrade, and should be quick for testing. Anyone interested?
     
  15. Josh Abbott

    Josh Abbott Member

    Joined:
    Oct 4, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Root Administrator
    I'd be happy to test out the fix on my test server. How do I install it?
     
  16. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi Josh,

    Here's a link to an RPM that you can download and install, and then test out. I put this on my personal website for easy access. Simply install the RPM, and you should be able to start testing your crons immediately.

    Let me know how it goes! Thank you!

    Code:
    rpm -Uvh http://houstondad.com/ea-php-cli-0.0.6-4.5.1.cpanel.x86_64.rpm
     
  17. Josh Abbott

    Josh Abbott Member

    Joined:
    Oct 4, 2015
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    Root Administrator
    I installed the RPM, and it looks like the fix is working perfectly.

    All the "/usr/bin/php" cron commands seem to be working in EA4 and I'm not seeing any errors. Thanks for the fix!
     
  18. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi Josh,

    Thanks for the update! We'll get this merged into master and sent out in our next release.
     
  19. Neso

    Neso Member

    Joined:
    Feb 11, 2009
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    Just to ask will this work also with using like thsi: php /some/file.php
     
  20. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    509
    Likes Received:
    64
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    I believe this should, yes. The PHP wrapper itself is pointing to php-cgi, so this should work no matter where it was called.
     
Loading...

Share This Page