PHP code example of johnroyer / php-job-runner
1. Go to this page and download the library: Download johnroyer/php-job-runner 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/ */
johnroyer / php-job-runner example snippets
class Cleanner extends \JobRunner\AbstractJob
{
private $jobId = 'clean-outdated-backup';
private $runTime = '0 3 * * *';
public function update(\SplSubject $runner)
{
// clean outdated backups
}
}
$runner = new JobRunner\Runner();
$runner->attach(new Cleanner);
$runner->attach(new SomeOtherJob);
// ...
$runner->notify(); // runner will notify job which should run at current time
bash
$ crontab -e
*/1 * * * * /usr/bin/php /path/to/bin/runner.php 2>&1 >/dev/null // check jobs every minutes