PHP Classes

File: examples/simple-example.php

Recommend this page to a friend!
  Classes of Camilo Sperberg  >  PID process check  >  examples/simple-example.php  >  Download  
File: examples/simple-example.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: Update of examples/simple-example.php
Date: 1 month ago
Size: 613 bytes


Class file image Download

// Load the class
// Load common file which will execute a long running function

// Enter here for how many seconds this example script should be running
$maxSeconds = 30;

try {
$pid = new unreal4u\pid();
} catch (\
Exception $e) {
// Calling die() is actually a bad practice, but this is just an example file

if (!
$pid->alreadyRunning) {
longRunningFunction($maxSeconds, $pid->pid);
} else {
'Script was already running, so we had to terminate the execution of it'.PHP_EOL);