mybuilder/cronos
Cronos is a Laravel-friendly task scheduling package for defining, running, and monitoring cron-style jobs from your app. Organize recurring tasks, trigger them on demand, and manage schedules with a clean API and sensible defaults.
crontab entries programmatically in PHP. It fits well in Laravel applications where:
laravel-scheduler) require dynamic crontab updates.schedule:run command but extends functionality for non-queue-based cron jobs (e.g., legacy scripts, external services).spatie/schedule (Laravel-native) or drush (Drupal), Cronos is PHP-agnostic but integrates cleanly with Laravel’s service container.CronosManager) for DI.php artisan cron:update).jobs.booted) to sync crontab on app startup.Model observers or eloquent-booted to trigger updates./etc/crontab requires root. Risk: Deployment pipelines must handle sudo/SSH keys securely.Cronos\Cronos in PHPUnit.Cronos\CronosInterface mocks.)Cronos\CronosInterface mocks.cron:deploy) to sync crontab on deploy.// app/Providers/CronosServiceProvider.php
public function register() {
$this->app->singleton(CronosManager::class, function ($app) {
return new CronosManager(new Cronos('/etc/crontab'));
});
}
@daily). Workaround: Use Cronos\CronExpression for validation.php artisan cron:validate)./etc/crontab before updates.php artisan cron:deploy as part of the deploy script.cron_jobs table for auditability./var/log/syslog) for errors.Cronos\Cronos::getCrontab() to inspect current entries.Log::debug() to trace cron updates.cron:rollback Artisan command./etc/crontab at a time.
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cronos package breaks | No cron jobs run | Fork and maintain locally. |
Permission denied on /etc/crontab |
Deployment fails | Use SSH keys or deployment user with sudo. |
| Concurrent crontab updates | Corrupted crontab | Implement a lock file or queue updates. |
| Cron syntax error | Job fails silently | Validate expressions in CI. |
| Server reboot | Lost in-memory state (none) | Cron entries persist in /etc/crontab. |
cron:deploy workflow in the README.* * * * *).CRONTAB_BACKUP step to deployment scripts./etc/crontab from backups.Cronos\CronExpression).cron:deploy command (mock Cronos).How can I help you explore Laravel packages today?