Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/9847-cron-php-script/
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.
Link to comment
https://forums.phpfreaks.com/topic/9847-cron-php-script/#findComment-36575
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.