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.

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:
    331
    Likes Received:
    0
    Trophy Points:
    16
    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
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    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.
     
  3. Czaries

    Czaries Registered

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

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

Share This Page