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.

cron job failing - Permission denied:

Discussion in 'General Discussion' started by cloudbase, Jan 24, 2012.

  1. cloudbase

    cloudbase Registered

    Joined:
    Jan 24, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Good-day yaAll,
    I could be in the wrong place, so forgive me. But please would someone explain where my error is?


    I have set up the following cron job in cPanel to test it's actions while changing "minutes"
    47 * * * * /home/xx/public_html/xx/PHPcRon.php

    The following message is delivered to me from cron when it runs

    <b>Warning</b>: ftp_get(/home/xx/public_html/xx/db/Images/Weather/Jet/jsnh-000.gif) [<a href='function.ftp-get'>function.ftp-get</a>]: failed to open stream: Permission denied in <b>/home/xx/public_html/xx/PHPcRon.php</b> on line <b>131</b><br />

    so aparently the path to the cron job is correct and the file does exist at /home/xx/public_html/xx/db/Images/Weather/Jet/jsnh-000.gif
    However the "Permission denied" is preventing the script from executing.
    file PHPcRon.php is 0766
    folder /home/xx/public_html/xx/db/Images/Weather/Jet/ is 0777
    and file jsnh-000.gif is 0644

    What has me confused is that earlier, before using cRon, I was able to execute PHPcRon.php successfully buy calling it through a Admin page load. PhpcRon.php is a script that uploads specific images that are updated regularly (weather data) to my server, then re-sized to a format suitable for my page display. When loaded by a client the page calls all the images in a particular directory and displays them in slide show fashion. I noticed the Owner is assigned to 99 99 during my PHP script execution. This might be another issue? and could be related?

    So my question is what do I need to fix to make PHPcRon.php run from cRon?
    Am I missing something with my thoughts?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you confirm if that's the exact cron job you have configured? If so, it's missing the PHP interpreter. Here is an example of a valid cron job:

    Code:
    /usr/bin/php /path/to/your/php/script.php
    Thank you.
     
  3. cloudbase

    cloudbase Registered

    Joined:
    Jan 24, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks for the quick answer, my reply. Yes that is the exact cron job /path/to/script
    The first line within .php contains the PHP interpreter as I understood from another post elsewhere.
    #!/usr/bin/php
    Is this not correct?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, please include the PHP interpreter in the cron job in order to execute the PHP file. Let us know if you still encounter the same error message. In the following example, the "/usr/bin/php" entry is required.

    Code:
    /usr/bin/php /path/to/your/php/script.php
    Thank you.
     
  5. cloudbase

    cloudbase Registered

    Joined:
    Jan 24, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Unfortunatly it continues to fail with the same message as before.
    <b>Warning</b>: ftp_get(/home/xx/public_html/xx/db/Images/Weather/Jet/jsnh-000.gif) [<a href='function.ftp-get'>function.ftp-get</a>]: failed to open stream: Permission denied in <b>/home/xx/public_html/xx/PHPcRon.php</b> on line <b>131</b><br />
    Having changed the cron job to
    8 * * * * /usr/bin/php /home/xx/public_html/xx/PHPcRon.php
    as well as removing #!/usr/bin/php from the script
     
    #5 cloudbase, Jan 24, 2012
    Last edited: Jan 24, 2012
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Do you have shell access to your account? If so, try running the command manually via shell to determine if you receive the same output. If you do, it's possible your PHP code is attempting to access a file it does not have access to. You can check the file ownership, or consider contacting your web hosting provider so they can check from the root level.

    Thank you.
     
  7. cloudbase

    cloudbase Registered

    Joined:
    Jan 24, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Okay, I think? Thank-you for your help.
    You lead me to thinking that by removing (simply renaming for now) the existing directory making an empty one with the same name (ie Jet) then letting cron and .php do their thing it might resolve the permissions.
    Well, it worked!!! Just ran it twice without error.
    Summerizing this issue as I see it my earlier testing Admin page load running .php created the files as user 99 99 (nobody?) therefore my attempts now running cron.php as owner failed permissions.
    Thank you very much Michael, as you see I am just learning and you have greatly helped me today.
    THANKS!!!
     
Loading...

Share This Page