Back-end execution

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Well, if going by the above post.. you wouldn't need two scripts.

Code: Select all

ignore_user_abort(true);
set_time_limit(0);

while(true)
{
     //actions here
     sleep(100); // or how many ever seconds you want the script to be halted for
}
Of course there is a problem here. If the server shuts off or apache stops running or many other things.. the script will not be executing. It should be performed as a cron job.

A cron job is a task that the server does automatically (without anyone visiting a page). A lot of control panels offer an interface to cron, making it easy to set up a cron.

Yours might look like this

Code: Select all

/usr/bin/php /home/myaccount/public_html/my_script.php
In the first part of that, /usr/bin/php is the path (or changed to the path) of php on your server. The second part is the location of the script you want to be ran automatically.

You can set your cronjobs to run every second, every minute, hour, day, etc etc etc... any time you want.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

scottayy wrote:You can set your cronjobs to run every second, every minute, hour, day, etc etc etc... any time you want.
In crond the minimal interval is 1 minute ...
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply