File: examples/longRunningFunction.php

Recommend this page to a friend!
  Classes of Camilo Sperberg  >  PID process check  >  examples/longRunningFunction.php  >  Download  
File: examples/longRunningFunction.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PID process check
Check if a PHP script is running using PID files
Author: By
Last change: Functions
Date: 6 years ago
Size: 430 bytes
 

Contents

Class file image Download
<?php

/**
 * This function will pause the execution of the script, simulating a long running process
 */
function longRunningFunction($timeout=1, $pid) {
    for (
$i = 1; $i != $timeout; $i++) {
       
printf(
           
'PID %d: %d/%d. Execute this script again within the time limit to test PID presence.'.PHP_EOL,
           
$pid,
           
$i,
           
$timeout
       
);
       
sleep(1);
    }

    return
true;
}


For more information send a message to info at phpclasses dot org.