Jump to content

Archived

This topic is now archived and is closed to further replies.

HAMM3R

cron php script

Recommended Posts

I have a php page that displays "Online" and "Offline" statuses for different hosts. It works by attempting to open a socket to those hosts. Because this can be a time intensive task to for 3 hosts every time the page loads, the page often is very slow to fully load. So how can I make the php script run with cron? That is, every 10 minutes run the status checks on the hosts and save the results in a flat text file or something. That way the website can just read the text file. This should dramatically reduce the loading time of the pages. I know about cron and how to add to it. So do I just put in cron the php script? I dont think the server can run the php script if it's not initiated in apache. So im lost. How do I make cron be able to run a php script much like apache would? Ive seen this done before with news sites and such. Thanks in advance!

Austin

Share this post


Link to post
Share on other sites
The command would be something like:

0 3 * * * /usr/local/bin/php /usr/home/*username*/public_html/script.php

The second part of the command "/usr/local/bin/php" points to the PHP install on the server, the script is run through the command line rather than through Apache.

Share this post


Link to post
Share on other sites
Instead of using /usr/local/bin/php

I've used the lynx text webbrower and pointed it to the php file.

Though I'm sure its quicker to do the other ;)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.