Download the PHP package y0lk/jobby without Composer
On this page you can find all versions of the php package y0lk/jobby. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jobby
Jobby, a PHP cron job manager
Install the master jobby cron job, and it will manage all your offline tasks. Add jobs without modifying crontab. Jobby can handle logging, locking, error emails and more.
This repository is a maintained fork of the original abandoned hellogerard/jobby package.
The Composer package name is y0lk/jobby, while the PHP namespace remains Jobby\.
The first release of this fork is 4.0.0 because it includes breaking package and mailer changes.
Current development targets PHP 8.0+ and uses opis/closure 4.x for closure serialization.
Tests
- docker run --rm --interactive --tty -v $(pwd):/app composer:2.0.7 composer install
- docker run -v $(pwd):/var/app php:8.0-cli php /var/app/vendor/bin/phpunit /var/app/tests/
Features
- Maintain one master crontab job.
- Jobs run via PHP, so you can run them under any programmatic conditions.
- Use ordinary crontab schedule syntax (powered by the excellent
cron-expression). - Run only one copy of a job at a given time.
- Send email whenever a job exits with an error status.
- Run job as another user, if crontab user has
sudoprivileges. - Run only on certain hostnames (handy in webfarms).
- Theoretical Windows support (but not ever tested)
Getting Started
Installation
The recommended way to install Jobby is through Composer:
Then add the following line to your (or whomever's) crontab:
After Jobby installs, you can copy an example file to the project root.
If you are migrating from the abandoned package, replace hellogerard/jobby with y0lk/jobby in your composer.json.
See UPGRADE-4.0 for the full migration notes.
Running a job
Examples
Logging
Disabling a command
Running closures
When running closures, beware that nothing outside of the closure is visible (see #93)!
Closures are serialized directly through opis/closure 4.x, so you do not need to wrap them manually.
Using a DateTime
Using a Custom Scheduler
Supported Options
Each job requires these:
| Key | Type | Description |
|---|---|---|
| schedule | string | Crontab schedule format (man -s 5 crontab) or DateTime format (Y-m-d H:i:s) or callable (function(): Bool { /* ... */ }) |
| command | string | The shell command to run (exclusive-or with closure) |
| closure | Closure | The anonymous PHP function to run (exclusive-or with command) |
The options listed below can be applied to an individual job or globally through the Jobby constructor.
Global options will be used as default values, and individual jobs can override them.
| Option | Type | Default | Description |
|---|---|---|---|
| runAs | string | null | Run as this user, if crontab user has sudo privileges |
| debug | boolean | false | Send jobby internal messages to 'debug.log' |
| Filtering | Options to determine whether the job should run or not | ||
| environment | string | null or getenv('APPLICATION_ENV') |
Development environment for this job |
| runOnHost | string | gethostname() |
Run jobs only on this hostname |
| maxRuntime | integer | null | Maximum execution time for this job (in seconds) |
| enabled | boolean | true | Run this job at scheduled times |
| haltDir | string | null | A job will not run if this directory contains a file bearing the job's name |
| Logging | Options for logging | ||
| output | string | /dev/null | Redirect stdout and stderr to this file |
| output_stdout | string | value from output option |
Redirect stdout to this file |
| output_stderr | string | value from output option |
Redirect stderr to this file |
| dateFormat | string | Y-m-d H:i:s | Format for dates on jobby log messages |
| Mailing | Options for emailing errors | ||
| recipients | string | null | Comma-separated string of email addresses |
| mailer | string | sendmail | Email transport handled by PHPMailer: sendmail or smtp or mail |
| smtpHost | string | null | SMTP host, if mailer is smtp |
| smtpPort | integer | 25 | SMTP port, if mailer is smtp |
| smtpUsername | string | null | SMTP user, if mailer is smtp |
| smtpPassword | string | null | SMTP password, if mailer is smtp |
| smtpSecurity | string | null | SMTP security option: ssl or tls, if mailer is smtp |
| smtpSender | string | derived from hostname | The sender and from addresses used in SMTP notices, normalized to a valid email address when needed |
| smtpSenderName | string | Jobby | The name used in the from field for SMTP messages |
Error email delivery is powered by phpmailer/phpmailer.
Symfony integration
Symfony bundle for Jobby - imper86/jobby-cron-bundle
Credits
Developed before, but since inspired by whenever.
All versions of jobby with dependencies
dragonmantank/cron-expression Version ^3.0
opis/closure Version ^4.5
phpmailer/phpmailer Version ^7.0