|
Tick (System updates)
|
|
05-25-2010, 02:21 AM
Post: #1
|
|||
|
|||
|
Tick (System updates)
I've played around with the idea of writing a PHP/AJAX mud for several years now. At one point, I had something that resembled a workable prototype, but ultimately gave up on it due to time restrictions. I picked up a few tricks along the way, one of which I will share in this post.
If you are using a Unix/Linux based system and want to dictate system events using CRON you'll find that the minimum interval you can have is 1 minute. The specifications for my prototype called for a tick at intervals of 30 seconds, so I found a work around. First, you setup CRON to call your update script (/home/cron/update.php for simplicity), Cron Code: ## Updates on the minute, every minuteThen, in your update.php script, you call PHP's built in sleep function. Sleep delays the execution of code by N seconds. update.php PHP Code: // Execute update function |
|||
|
05-25-2010, 02:29 AM
Post: #2
|
|||
|
|||
|
RE: Tick (System updates)
Thanks for the tip! That should help those who prefer to do this in PHP keep their system updating. Very nice
|
|||
|
05-25-2010, 08:04 AM
Post: #3
|
|||
|
|||
|
RE: Tick (System updates)
I experimented with Cron a while back. If you plan on using it make sure that the host you plan on working with supports it, as many inexpensive php hosts do not. If your host does not support cron, but you don't want to change to a new host for whatever reason, there is web-based solutions that are specifically built for Cron such as http://www.webcron.org/
which lets you execute a cron job up to every 30 seconds. I used webcron a couple months back and was really satisfied with the service overall. Just remember to prevent third parties from connecting to your update script ![]() Also is sleep() a blocking call? |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)

Search
Member List
Calendar
Help



