PHP Classes

File: examples/job-with-fatal-error.php

Recommend this page to a friend!
  Classes of Camilo Sperberg  >  PID process check  >  examples/job-with-fatal-error.php  >  Download  
File: examples/job-with-fatal-error.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/job-with-fatal-error.php
Date: 1 month ago
Size: 728 bytes


Class file image Download

// Load the class

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

try {
$options = array('timeout' => 10);
$pid = new unreal4u\pid($options);
} catch (\
Exception $e) {
// Ok, you should never call die or exit within your script, but this is just an example file

if (
$pid->alreadyRunning) {
sprintf('Already running an instance of this script (pid #%s)'.PHP_EOL, $pid->pid));

printf('Not running any instance of %s, this is PID %d'.PHP_EOL, basename(__FILE__), $pid->pid);

// Produce an intentional fatal error, this will NOT delete the PID