Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timers

Status
Not open for further replies.

GPhilipp

Programmer
Apr 12, 2010
20
US
Hello

I am writing a script in PHP (and I am not very strong in this :-( ). This script needs to check the status of several items periodically. New items are added constantly and they end constantly.

I was thinking to this with independent timers, but in my research I found:
- PHP does not do multi threading. Therefore I can not run other code during the time the timers run.
- The timer classes I have found are not really timers, they just calculate the elapsed time between start and now.
- i read that having multiple timers run at the same time is not efficient in PHP. But I am not sure how to create 1 timer which is flexible enough to handle upcoming items. I could check through a MySQL table, but time is of the essence in my routine.
- I saw the GTK extension ( but I am not sure if this helps me with what I need. The sample I found looks ok ( However, I am not sure if my Host has that extension installed, but they probably would.
What is usually the preferred method/structure to write something like that?

Any help is greatly appreciated!

Gunnar.
 
Hi

Gunnar said:
PHP does not do multi threading.
The best you can use is [tt]pcntl_fork()[/tt]. Of course, only on Unix. And probably no host will allow its use.
Gunnar said:
This script needs to check the status of several items periodically.
If you want a web script, your problem is that their execution time is limited. By default to 30 seconds.
Gunnar said:
I saw the GTK extension ( but I am not sure if this helps me with what I need. [gray](...)[/gray] However, I am not sure if my Host has that extension installed, but they probably would.
GTK is for GUI. If you want a web script, it will not help you. And probably no host will install it.

See if you host allows cron jobs. Or use a free web cron service.


Feherke.
 
Hello Feherke

Thank you for your reply and info.

After more discussion with my partner here I found that I don't realy need a 'true' timer. I can use the timer class discribed earlier and when the user on the webpage needs to check it, it just ask the 'wann-be' timer for the time status.

Thanks again for your post.

Gunnar
 
So you are wanting to write some PHP which will run as an application rather than as a web page?
Is there any reason why you have to do it in PHP?,
What platform are you running on?,
years ago I did some timer work on windows running VB6. That is now way out of support support so you might want to look at the .NET platform
 
It took me so long to write my reply feherke got in !
So you want to run it as a web page? - good luck !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top