setono / cron-builder
Build cron files from a config in your repository
Installs: 22 853
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 5
Requires
- php: ^7.4
- ext-mbstring: *
- dragonmantank/cron-expression: ^2.0 || ^3.0
- symfony/config: ^4.4 || ^5.0
- symfony/expression-language: ^4.4 || ^5.0
- symfony/finder: ^4.4 || ^5.0
- symfony/options-resolver: ^4.4 || ^5.0
- symfony/process: ^4.4 || ^5.0
- symfony/yaml: ^4.4 || ^5.0
- thecodingmachine/safe: ^1.0
- webmozart/assert: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.3
- setono/code-quality-pack: ^1.4
- dev-master / 1.0.x-dev
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.0
- dev-dependabot/github_actions/actions/cache-3.2.3
- dev-dependabot/github_actions/actions/checkout-3.3.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.23.0
- dev-renovate/configure
- dev-dependabot/composer/setono/code-quality-pack-tw-1.4or-tw-2.0
This package is auto-updated.
Last update: 2023-03-09 17:30:02 UTC
README
Installation
$ composer require setono/cron-builder
Usage
The following two code snippets outlines the simplest usage of the cron builder.
1. Add your commands
The default directory to look for cronjobs is inside etc/cronjobs
. This can be changed in the options of the CronBuilder
.
Here we define two jobs. Two PHP commands that run on the given time.
# etc/cronjobs/jobs.yaml - schedule: "0 0 * * *" command: "php first-script.php" - schedule: "1 0 * * *" command: "php second-script.php"
2. Build the crontab
When your cronjobs are defined, you can build the crontab file:
<?php use Setono\CronBuilder\CronBuilder; $cronBuilder = new CronBuilder(); $crontab = $cronBuilder->build();
This will output the following:
###> Automatically generated by Setono Cron Builder - Do not edit ###
0 0 * * * php first-script.php
1 0 * * * php second-script.php
###< Automatically generated by Setono Cron Builder - Do not edit ###
You can save this in a file named crontab.txt
and add it to your crontab like this:
$ cat crontab.txt | crontab -