SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist bradical1379's Avatar
    Join Date
    Feb 2007
    Posts
    443
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CRON or automated task to execute scripts

    I have a number of PHP scripts that I wrote that I use to compile information across the web. I have an unique script for each page that I attempt to get information from, however, since I am trying to execute numerous scripts in a single cron task, it looks like the script is erroring out (and not telling me why).

    This is my current script that I have running every night:

    Code PHP:
    $file = @file_get_contents('http://site.mine.com/pages/param1');
    $file = @file_get_contents('http://site.mine.com/pages/param2');
    $file = @file_get_contents('http://site.mine.com/pages/param3');

    Each of the three scripts are also executable by just visiting through a browser, but they typically take too long to execute or error 500 out.

    What is the correct way to mimic viewing a page through an automated task?

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,095
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Since you do this in a cron job I'd go for curl or wget. No need to fire up PHP for this.

    multiple runs are run independently of each other so if one of them crashes all the others still go through.

    Code:
    !#/bin/sh
    
    /path/to/curl http://site.mine.com/pages/param1 >> command1
    /path/to/curl http://site.mine.com/pages/param2 >> command2
    /path/to/curl http://site.mine.com/pages/param3 >> command3
    It will write the output for each of the "downloads" to the files command1, command2, command3
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •