byfareska / cron-bundle
Symfony cron
Installs: 2 166
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- symfony/framework-bundle: ^3.4|^4.4|^5.0|^6.0
Requires (Dev)
- symfony/symfony: >=4.0
This package is not auto-updated.
Last update: 2024-11-11 09:19:29 UTC
README
Fast setup
- Add to cron
* * * * * php bin/console cron:run
- Create a class that implements
\Byfareska\Cron\Task\ScheduledTask
, for example:
final class DeleteFileEveryHourTask implements ScheduledTask { public function cronInvoke(DateTimeInterface $now, bool $forceRun, OutputInterface $output): bool { if($forceRun || $now->format('i') === '0'){ $this(); return true; } return false; } public function __invoke(): void { unlink('/var/example'); } }
Useful commands
Force to run some tasks
php bin/console cron:run --task=App\\Task\\DeleteFileEveryHourTask,App\\Task\\AnotherTask
List all registered tasks
php bin/console debug:container --tag=cron.task