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!

HOW: Running a PHP script under cronjob.

Discussion in 'General Discussion' started by SuperBaby, Dec 18, 2005.

  1. SuperBaby

    SuperBaby Well-Known Member

    Joined:
    Nov 27, 2003
    Messages:
    336
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Thailand
    cPanel Access Level:
    Website Owner
    Twitter:
    I setup a cronjob under cPanel for my auction site. This cronjob is scheduled to run once a day. But I sometimes receive error reporting via email:

    /bin/sh: line 1: /home/username/public_html/cron/cron1.php: Permission denied

    Since the cron is setup to run ONCE a day and I am not getting this error everyday, I am not sure if the cronjob is setup properly.

    The original cron command in the auction program manual is:
    GET http://www.mydomain.com/cron/cron1.php >/dev/null

    Since it gave me constant errors, I use this instead:
    /home/username/public_html/cron/cron1.php
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    21
    Trophy Points:
    463
    Location:
    Go on, have a guess
    If you don't put the interpreter before the script, i.e. /usr/bin/php <script-name>, then you do have to make sure that the first line in the script has a shebang line, i.e. #!/usr/bin/php otherwise cron has no idea how to run the script.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Czaries

    Czaries Registered

    Joined:
    Dec 19, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    151
    Many times this will work fine:

    php /home/username/public_html/cron/cron1.php
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice