SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict AfroNinja's Avatar
    Join Date
    Oct 2006
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php auto-prepend to crontab files

    I have a php value set through httpd.conf that auto-prepends a common function file to every .php page on my site.

    I have several .php crontab files that require this common function file to run. However the crontab keeps returning errors to me that the functions can't be found. So I'm assuming the file isn't getting pre-pended when run by the server itself.

    does this sound right? Is there a way around this? will I have to go to every crontab file and manually insert

    require('/path/common_functions.php');

    ?
    The Flash Gaming Network
    Editorial reviews for the latest flash games!
    Afro Ninja Productions
    Original flash games and content from a guy with an afro

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your settings from httpd.conf are applied only when php is run through the webserver. You would need to use wget in your cron job command to fetch the url which will execute your php script.

    Otherwise, if you just execute php directly, your executing a potentially completely seperate copy of php which will not have anything to do with your webserver at all. It may be a different version of php, and may use a different php.ini file, and almost certainly has different default config settings.

    http://www.sitepoint.com/article/introducing-cron/

    If you don't use wget, you're essentially running php from the command line interface. You need to read this then
    http://www.php.net/features.commandline

  3. #3
    SitePoint Addict AfroNinja's Avatar
    Join Date
    Oct 2006
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, I couldn't use wget because my cron scripts are above the root so they have no url. if the were at the root or below they could be accessed by web browsers where they could be executed multiple times.

    I think it'll be easiest to just run an include or require () for the functions file each time
    The Flash Gaming Network
    Editorial reviews for the latest flash games!
    Afro Ninja Productions
    Original flash games and content from a guy with an afro


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
  •