PHP code example of ofbeaton / command-running

1. Go to this page and download the library: Download ofbeaton/command-running 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/ */

    

ofbeaton / command-running example snippets


    $pidfile = 'mypidfile.txt';
    $running = new \Ofbeaton\Command\Running($pidfile);

    $ok = $running->claimPidFile();
    if ($ok === false) {
        echo 'We are currently already running'.PHP_EOL;
        exit;
    }

    // your code

    // at the end of your program
    $running->releasePidFile();

bash
# Install Composer
curl -sS https://getcomposer.org/installer | php