filippo-toso/php-supervisor

A simple supervisor class that allows to run long lived PHP scripts from the crontab

v1.0.1 2021-08-19 09:46 UTC

This package is auto-updated.

Last update: 2024-10-19 16:29:01 UTC


README

A simple supervisor tool that allows to run PHP long running scripts through crontab.

Requirements

  • PHP 5.6+

Installing

Use Composer to install it:

composer require filippo-toso/php-supervisor

Using It

Create a simple PHP script with a code like the following:

use FilippoToso\PhpSupervisor\Supervisor;

Supervisor::run(function() {
    // Do your long lived stuff here    
}, __DIR__ . '/lock.dat', __DIR__ . '/stop.dat');

Then call the script every minute from the crontab. The code in the closure will be kept running untill the $stopFile specified in the third parameter exists (stop.dat in the example).