SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    automatic server.

    I've been surfing the web for quite a while now but haven't found what I am looking for. I'm looking for a script that doesn't have to be activated by a visitor, but keeps running on the server. I'd like to store the data that my script gets from other pages.

    If you look at http://www.dijksma.net , you'll see that it's a financial site that displays headlines from leading financial newspapers. The script is working fine, but, however, it takes to long to load. If I just can get a script that stores the data every minute, the visitor doesn't have to wait on the other servers. I just have to open one single file that is stored on my own server, therefor the loading time will be decreased.

    Please help me if you can, and if you know the right word for it, don't hesitate to anwser!

    Dijksma

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you need to use is a CRON job. This allows will run a script at a time specified by you, for example every 5 minutes.

    What you could do is get the headlines and store them in a database then you just need one script to get the headlines from the database when someone visits your site.

    Sean

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a feauture that your host has to support. All it does is call the script to grab the headlines, the same has if you called the script through your browser. However, it does it in the background at times you tell it.

    Check with your host if they support it! If not there are other ways, but they are not as efficient.

    Sean

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, did you just delete your post or did vB go freaky ?

    Sean

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you see it in this file http://www.dijksma.net/php.php ??? If it is possible

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, sorry you can not tell from that. I tried to see what your host is but could not. They have probably got a support section on their website where it will tell you if Cron is available. If you have a control pannel for your account there would be a section in there for Cron jobs.

    Sean

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i believe it's possible.
    Is it possible to give me an example script? The scripts i can find are not understandable. Just a basic script.

  8. #8
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have not tried any scripts that use Cron before. I did find this http://www.cogit8.org/emrem/

    To run this you will need PHP, Perl and MySQL. What it does is send an email to an address at a specified time. It is like an email reminder program.

    Let me know if it works!

    Sean

  9. #9
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have telnet/ssh access to your site?

    If so, type "crontab -l" and see what you get back.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll check it out

  11. #11
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, do you know what either Telnet or SSH are?

  12. #12
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, know telnet, but for some reason i can't log in... But I do believe it's installed. The best way to find out is to try it...

  13. #13
    SitePoint Enthusiast Stallion's Avatar
    Join Date
    Jan 2001
    Location
    Cumberland, RI, US
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You edited your earlier post and now I look like a dick. ;-)

    I'll have to apply the five minute rule from now on...

  14. #14
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol Well sorry
    Then we start at the beginning.
    This is my current script that saves the data to a file. But It does not work. please help me with this firts than we will go to the cron.

    <?

    $fileArray = file("http://www.dft.nl");

    if ( ! $fileArray ) {
    echo '<tr><td>The news interface is down for maintenance.</td></tr>',
    '</table></body></html>';
    break;
    }

    $searchStr ='<td colspan="2" align="left" class="stijgers" nowrap="nowrap">';
    $i = 0;
    foreach($fileArray AS $line) {
    if ( strstr($line, $searchStr) ) {
    $line = str_replace("/servlet/", "http://www.dft.nl/servlet/", $line );
    $file = fopen("store.inc","w+");
    fputs($file, $line);
    fclose($file);
    echo $line, "</tr><tr>\n";
    $i++;
    }
    if ( $i == 5 ) {
    break;
    }
    }
    ?>

  15. #15
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First, are you getting any error messages?

    Sean

  16. #16
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No I do not get any error messages but the script stores only the last headline.This is the script
    <?
    $leeg = "";
    $file = fopen("store.inc","w+");
    fputs($file, $leeg);
    fclose($file);

    ?>


    <?

    echo '<center><B>Het Financiele dagblad</B></center>';
    $fileArray = file("http://hfd.bvdep.com/Nieuwsdienst.asp");

    if ( ! $fileArray ) {
    echo '<tr><td>The news interface is down for maintenance.</td></tr>',
    '</table></body></html>';
    break;
    }

    $searchStr ='<tr><td class="tekstregulargrey">';
    $i = 0;
    foreach($fileArray AS $line) {
    if ( strstr($line, $searchStr) ) {
    $line = str_replace("ShowNews.asp?", "http://hfd.bvdep.com/ShowNews.asp?", $line );
    echo $line, "\n";

    $i++;
    }

    $file = fopen("store.inc","r+");
    $count = fread($file, filesize("store.inc"));
    fclose($file);

    $dirk = "$count $line \n";
    $file = fopen("store.inc","w+");
    fputs($file, $dirk);
    fclose($file);


    if ( $i == 10 ) {
    break;
    }
    }
    echo '<BR><BR><BR>';
    include("store.inc");
    ?>
    Last edited by dijksma; Jul 8, 2001 at 09:08.


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
  •