$Value) { file_get_contents($URL.'?MeasureId='.$Index.'&Value='.$Value); } } function RepeatFunction($Period, $Function) { while(1) { $StartTime = time(); $Function(); $EndTime = time(); $Delay = $Period - ($EndTime - $StartTime); if($Delay < 0) $Delay = 0; echo('Waiting '.$Delay.' seconds...'."\n"); sleep($Delay); } } RepeatFunction(60 * 60, 'ProcessMeasure');