SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2003
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using a cron job on this PHP file? Need some help.

    Hey,

    I'm running the following command (time: 5 * * * *) as a cron job on index.php under "Advanced" in my cPanel X:

    php -q /www/fastarcade/index.php > /www/fastarcade/build.html
    Build.html is not being updated every five minutes. In fact, it's not being updated at all. What's wrong?

    Thanks.

  2. #2
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the thing is that you might need the real full path to the script your running and the target file. Right now it looks like your using a path from your user directory but when you run a script from cron with /www it is looking for a www directory at the root of the filesystem not your user directory. That is my guess as to why its not working.
    Erh

  3. #3
    SitePoint Wizard Nikolas's Avatar
    Join Date
    Feb 2005
    Location
    Greece
    Posts
    1,222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think Mandibal is right. Another thing you can check is the permissions of the user that runs the cron. It must be the Apache user in order to work.

    If you want to get rid of this stuff you can create a script that will write the build.html and cron it with curl eg curl http://mysite.com/script.php

  4. #4
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also most likely need the full path to PHP. Such as..

    PHP Code:
     /usr/bin/php /home/user/site_dir/html/dir/cron_file.php > /dev/null 2>&

  5. #5
    SitePoint Wizard HarryR's Avatar
    Join Date
    Dec 2004
    Location
    London, UK
    Posts
    1,376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may also have forgotten that '5 * * * *' means to run the script at 5 minutes past every hour, instead of every 5 minutes.

    To run every 5 minutes you would use '0,5,10,15,20,25,30,35,40,45,50,55 * * * *'

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could use

    */5 * * * *

    to run it every 5 minutes.
    Brock Ferguson
    Lead Developer, Caribou CMS
    A Subscription/Membership CMS and Ecommerce Platform - FREE Trial


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •