PHP code example of toflar / cronjob-supervisor

1. Go to this page and download the library: Download toflar/cronjob-supervisor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

toflar / cronjob-supervisor example snippets




ymfony\Component\Process\Process;
use Toflar\CronjobSupervisor\BasicCommand;
use Toflar\CronjobSupervisor\Supervisor;

    $supervisor = Supervisor::withDefaultProviders('/some/directory/you/want/to/store/your/state');
    
    $supervisor
        ->withCommand(new BasicCommand('sleep 10', 2, function () {
            return new Process(['sleep', '10']);
        }))
        ->withCommand(new BasicCommand('sleep 29', 4, function () {
            return new Process(['sleep', '29']);
        }))
    ->supervise()
;