q-alliance / crontab-manager
Crontab Manager
Installs: 1 690
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 2
Open Issues: 0
Requires
- symfony/process: >3.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpstan/phpstan: >0.11
- phpunit/phpunit: ^7.3
README
Installation:
$ composer require q-alliance/crontab-manager
Usage:
- create a reader, send username as parameter (use common sense, you cannot set root crontab if you are running this as joeaverage user)
- create a writer and inject the reader
- run update with array of cron jobs to add
for example:
<?php use QAlliance\CrontabManager\Factory; $listOfCronjobs = [ '3 */4 * * * /home/test/dev/bittrex-logger/bin/console bittrex:fetch --verbose', '9 */12 * * 0 /home/test/keke/vendor/bin/foobar run --die', '11 1 * * 1 /usr/bin/php /var/www/sample.q-software.com/bin/console app:timerweekteamwork', ]; $writer = Factory::createWriter('www-data'); $writer->updateManagedCrontab($cronJobs);
- all users current cron jobs will be left intact
- a new
block
of cron jobs will be added to crontab, using the list provided - this block is managed by this library - if you add or remove jobs from the array, they will be updated when you run the updateMangedCrontab method
- also see example.php in the root folder
Misc & TODO:
- tests
- create a symfony bundle to integrate this with Symfony 4 framework
- CLI command that can be run via composer install to auto-update your crontabs with every new release