HAMM3R Posted May 17, 2006 Share Posted May 17, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/9847-cron-php-script/ Share on other sites More sharing options...
zq29 Posted May 17, 2006 Share Posted May 17, 2006 The command would be something like:0 3 * * * /usr/local/bin/php /usr/home/*username*/public_html/script.phpThe 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. Quote Link to comment https://forums.phpfreaks.com/topic/9847-cron-php-script/#findComment-36575 Share on other sites More sharing options...
HAMM3R Posted May 17, 2006 Author Share Posted May 17, 2006 Awesome! Thanks SemiApocalyptic! Quote Link to comment https://forums.phpfreaks.com/topic/9847-cron-php-script/#findComment-36694 Share on other sites More sharing options...
SharkBait Posted May 19, 2006 Share Posted May 19, 2006 Instead of using /usr/local/bin/phpI've used the lynx text webbrower and pointed it to the php file.Though I'm sure its quicker to do the other ;) Quote Link to comment https://forums.phpfreaks.com/topic/9847-cron-php-script/#findComment-37252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.