{"id":21598100,"url":"https://github.com/matfish2/craft-console-scheduler","last_synced_at":"2026-02-11T18:32:51.143Z","repository":{"id":219316123,"uuid":"748737051","full_name":"matfish2/craft-console-scheduler","owner":"matfish2","description":"Schedule CraftCMS Console Commands in Code","archived":false,"fork":false,"pushed_at":"2025-02-28T07:09:26.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T14:17:26.174Z","etag":null,"topics":["craft4","craftcms","craftcms-plugin","cron-jobs","crontab","scheduler"],"latest_commit_sha":null,"homepage":"https://plugins.craftcms.com/console-scheduler?craft4","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matfish2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-26T16:51:05.000Z","updated_at":"2025-02-28T07:09:29.000Z","dependencies_parsed_at":"2025-01-24T17:44:10.071Z","dependency_job_id":"78901172-0ce2-454f-af46-bdcc56d3f43b","html_url":"https://github.com/matfish2/craft-console-scheduler","commit_stats":null,"previous_names":["matfish2/craft-console-scheduler"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-console-scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-console-scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-console-scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matfish2%2Fcraft-console-scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matfish2","download_url":"https://codeload.github.com/matfish2/craft-console-scheduler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244210624,"owners_count":20416494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["craft4","craftcms","craftcms-plugin","cron-jobs","crontab","scheduler"],"created_at":"2024-11-24T18:11:17.278Z","updated_at":"2026-02-11T18:32:46.118Z","avatar_url":"https://github.com/matfish2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Console Scheduler\n\nThis package adds the ability to schedule console commands directly from code.\n\n## Why?\n\nWhile you may write a cron configuration entry for each task you need to schedule on your server, this can quickly\nbecome a pain, because your task schedule is not recorded to source control and you must SSH into your server to view\nyour existing cron entries, add additional entries or change the schedule.\n\nThis package will allow you to:\n1. Define only one command in `crontab` and the rest will be handled in code.\n2. Use intuitive and readable fluent syntax to define the frequency.\n3. Log all executed commands to a dedicated `console-scheduler-{date}.log` file, along with any output the command may generate and the exit code.\n\n## Installation\n\n1. Include the package:\n\n```\ncomposer require matfish/craft-console-scheduler\n```\n\n2. Install the plugin:\n\n```\nphp craft plugin/install console-scheduler\n```\n\n## Initial Setup\n\nAdd the following line to your `crontab`\n\n```\n* * * * * /var/www/my-site/php craft console-scheduler/schedule \u003e\u003e /dev/null 2\u003e\u00261\n```\n\nThis will ensure the scheduler runs every minute, and checks for due commands to run.\nIt is recommended to set the frequency according to the highest frequency your project requires.\nE.g if the most frequent command you have runs hourly, there is no need to call the scheduler every minute, and you can use `0 * * * *` instead\n\n## Usage\n\n1. Create a `config/console-scheduler.php` file \n2. Add schedules according to the following example:\n\n```php\nreturn [\n    'schedules' =\u003e static function (\\matfish\\ConsoleScheduler\\Schedule\\SchedulesCollection $schedule) {\n        $schedule-\u003ecommand('activity-logs/logs/prune --days=30 --interactive=0')-\u003emonthly();\n        $schedule-\u003ecommand('cache/clear')-\u003edaily()-\u003eat('23:00');\n    }\n];\n```\n\nSupported frequencies:\n\n* `everyMinute()`\n* `everyTwoMinutes()`\n* `everyThreeMinutes()`\n* `everyFourMinutes()`\n* `everyFiveMinutes()`\n* `everyTenMinutes()`\n* `everyFifteenMinutes()`\n* `everyThirtyMinutes()`\n* `hourly()`\n* `hourlyAt($time)`\n* `everyOddHour()`\n* `everyTwoHours()`\n* `everyThreeHours()`\n* `everyFourHours()`\n* `everySixHours()`\n* `daily()`\n* `dailyAt($time)`\n* `twiceDaily($hour1 = 1,$hour2 = 13)`\n* `twiceDailyAt($hour1 = 1,$hour2 = 13, $offset = 0)`\n* `weekdays()`\n* `weedends()`\n* `days($day1,$day2, $day3, etc)` - specific days of week\n* `sundays()`\n* `mondays()`\n* `tuesdays()`\n* `wednesdays()`\n* `thrusdays()`\n* `fridays()`\n* `satrudays()`\n* `weekly()`\n* `weeklyOn($dayOfWeek, $time = '0:0')`\n* `monthly()`\n* `monthlyOn($dayOfMonth, $time)`\n* `twiceMonthly($firstDay = 1, $secondDay = 16, $time = '0:0')`\n* `lastDayOfMonth($time = '0:0')`\n* `quarterly()`\n* `quarterlyOn($dayOfQuarter = 1, $time = '0:0')`\n* `yearly()`\n* `yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')`\n\nMethods without a specified time can be followed by an `at` method using fluent syntax. \n\nIf you need more control you can also use the raw `cron` method to define your own frequency, e.g:\n```php\n$schedule-\u003ecommand('my/cool/command')-\u003ecron('*/5 * 3 7 4'); // Every 5 minutes, on day 3 of the month, and on Thursday, only in July\n```\n\n## Testing\nWhen `CRAFT_ENVIRONMENT=dev` you can pass a `--test` option to the scheduler (in Y-m-d H:i format), to mimic a time which is not the present, and make sure the commands run as expected.\nE.g:\n```\nphp craft console-scheduler/schedule --test=\"2024-01-26 19:05\" \n```\n\nThe `--test` option will be ignored in any other environment.\n\n## License\n\nYou can try Console Scheduler in a development environment for as long as you like. Once your site goes live, you are\nrequired\nto purchase a license for the plugin. License is purchasable through\nthe [Craft Plugin Store](https://plugins.craftcms.com/console-scheduler).\n\nFor more information, see\nCraft's [Commercial Plugin Licensing](https://craftcms.com/docs/4.x/plugins.html#commercial-plugin-licensing).\n\n## Requirements\n\nThis plugin requires Craft CMS 4.0.0 or later.\n\n## Acknowledgements\nThis package is heavily inspired by Laravel's [Task Scheduling](https://laravel.com/docs/11.x/scheduling) feature.\n\n## Contribution Guidelines\n\nCommunity is at the heart of open-source projects. We are always happy to receive constructive feedback from users to\nincrementally improve the product and/or the documentation.\n\nBelow are a few simple rules that are designed to facilitate interactions and prevent misunderstandings:\n\nPlease only open a new issue for bug reports. For feature requests and questions open a\nnew [Discussion](https://github.com/matfish2/craft-console-scheduler/discussions) instead, and precede [FR] to the\ntitle.\n\nIf you wish to endorse an existing FR please just vote the OP up, while refraining from +1 replies.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Fcraft-console-scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatfish2%2Fcraft-console-scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatfish2%2Fcraft-console-scheduler/lists"}