Hi guys,

I've searched this forum and could not find any solution to it.
The problem is this:
I'm getting data from an external source every 10 seconds(approximately).
I want to execute some script every 10 seconds but there can't be even the smallest delay.
So if I would use a cronjob every minute that executes an php class every 10 seconds trough sleep there is some delay, not much but still small.
Is there some solution to this? Experience?

It would help me a lot!

janpieterz

If this is a local device, then I think that you are trying to use PHP for something that it wasn't really intended for but you may still be able to make it work. You receive data approximately every 10 seconds but you want your task to fire exactly every 10 seconds. It seems that what you'd really want is to start the task whenever the input is received so you don't have to worry about synchronization of the timing between the input and your program. If that isn't possible, then you may want to fire your task more often then 10 seconds (e.g. every second) so you can catch it whenever it arrives. Cron really isn't made to do this and I believe that the minimum interval is one minute. The link below addresses this and talks about some another lower-level approach. If you aren't on a dedicated server, you should forget about any requirements for exact timings.

http://www.linuxquestions.org/questions/programming-9/seting-cron-to-run-a-script-every-second-425623/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.