{"id":36374309,"url":"https://github.com/watchowl/cake-scheduler","last_synced_at":"2026-01-11T14:04:36.296Z","repository":{"id":62546789,"uuid":"104806973","full_name":"watchowl/cake-scheduler","owner":"watchowl","description":"Cron Scheduler for CakePHP","archived":false,"fork":false,"pushed_at":"2018-07-10T00:53:14.000Z","size":13,"stargazers_count":11,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-28T04:56:41.877Z","etag":null,"topics":["cakephp","cakephp-plugin","cakephp3","cronjob","cronjob-scheduler","crontab"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/watchowl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T22:08:38.000Z","updated_at":"2025-08-28T12:12:29.000Z","dependencies_parsed_at":"2022-11-02T22:16:00.777Z","dependency_job_id":null,"html_url":"https://github.com/watchowl/cake-scheduler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/watchowl/cake-scheduler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watchowl%2Fcake-scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watchowl%2Fcake-scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watchowl%2Fcake-scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watchowl%2Fcake-scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watchowl","download_url":"https://codeload.github.com/watchowl/cake-scheduler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watchowl%2Fcake-scheduler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28306985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cakephp","cakephp-plugin","cakephp3","cronjob","cronjob-scheduler","crontab"],"created_at":"2026-01-11T14:04:36.207Z","updated_at":"2026-01-11T14:04:36.269Z","avatar_url":"https://github.com/watchowl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CakeScheduler\nCron Scheduler Plugin for CakePHP 3\n\n## Table of Contents  \n- [Introduction](#installation)\n- [Why Use It](#why-use-it)\n- [Installation](#installation)\n- [Starting The Scheduler](#starting-the-scheduler)\n- [Defining Schedules](#defining-schedules)\n    - [Scheduling CakePHP Shell](#scheduling-cakephp-shell)\n    - [Scheduling Any Other Commands](#scheduling-any-other-commands)\n    - [Frequency Options](#frequency-options)\n- [Hooks](#hooks)\n    - [Before A Job Runs](#before-a-job-runs)\n    - [After A Job Is Finished](#after-a-job-is-finished)\n\t\t\n## Introduction \nCakeScheduler allows you to write cron jobs right from PHP files. \nIt works for CakePHP shell as well as any other valid PHP code. \nBasically it is a replacement of the conventional crontab file. \n\n## Why Use It\nThe conventional way of writing a cron job is to place an entry in the crontab file each time you \nneed to schedule a job. The problem with this approach is that you have to login(SSH) to the server \neach time. \n\nBy using CakeScheduler, we are able to place the cron jobs in the source control system and deploy \nthem to production just like any other PHP code.  \n\n## Installation\n\n+ To install the CakeScheduler plugin, you can use composer. From your application's ROOT directory (where composer.json file is located) run the following:\n\n    ```composer require watchowl/cake-scheduler```\n\n+ You will need to add the following line to your application's `config/bootstrap.php` file:\n\n    ```Plugin::load('WatchOwl/CakeScheduler');```\n\n    \n## Starting The Scheduler\n\nWe only need to install one ordinary cron job which runs every minute.\nThis cron job will enable CakeScheduler to schedule all the subsequent jobs:\n\n```* * * * * /path-to-project/bin/cake cake_scheduler run schedule:run```\n\n## Defining Schedules\nA schedule is basically a PHP file ending with **Tasks.php** and it must return the **CakeSchedule** object.\nAll schedules should be place inside a folder called **schedule**. This folder must reside at the root directory \nwhere composer.json file is located.\n\nFor example:\n```php\n// schedule/BackTasks.php\n$schedule = new \\WatchOwl\\CakeScheduler\\Schedule\\CakeSchedule();\n$schedule\n    -\u003erun('/usr/bin/php backup.php')\n    -\u003edaily()\n    -\u003edescription('Test');\nreturn $schedule;\n```\n\n### Scheduling CakePHP Shell\nTo schedule a CakePHP shell, call *CakeSchedule::shell*:\n\n```$schedule-\u003eshell('MyCake awesome')```\n\n### Scheduling Any Other Commands\nTo schedule any other commands, call *CakeSchedule::run*:\n\n```$cakeSchedule-\u003erun('/usr/bin/php backup.php')```\n\n### Frequency Options\n\nThere is plenty of ways to define the frequency of the execution:\n\n\n| Method        |   \tDescription |\n|---            |       ---     |\n| -\u003ecron()        |  the classic way of defining a schedule |\n| -\u003ehourly()      |  beginning of each hour|\n| -\u003edaily()   \t|  daily at midnight|\n| -\u003eweekly    \t|  sunday of each week\t|\n| -\u003emonthly()   \t|  first day of each month\t|\n| -\u003equarterly()   |  first day of each quarter\t|\n| -\u003eyearly()   \t|  first day of each year\t|\n| -\u003eeveryFiveMinutes() |    every five minutes      |\n| -\u003eeveryMinute()     |   every minute        |\n| -\u003eeveryTwelveHours() |   every twelve hours       |\n| -\u003eeveryMonth()    | every month          |\n| -\u003eeverySixMonths()  |  every six months          |\n| -\u003eeveryFifteenDays()    |  every fifteen days        |\n| -\u003eon('13:30 2016-03-01') | at a specific date and time |\n| -\u003eat('13:30') | at a specific time |\n\n\nUnder the hood, CakeSchedule is using the great \n[lavary/crunz](https://github.com/lavary/crunz#frequency-of-execution) library.\nIt has a large number of options for us to configure the frequency of the execution.\nCheck out its official documentation if you are looking for more available frequency.   \n\n## Hooks\nHooks make it easy to integrate with other services such as [www.watchowl.io](http://www.watchowl.io). \n\n### Before A Job Runs\nTo do something before a job is executed, we can use the *before()* hook:\n\nFor example:\n\n```php\n$schedule = new \\WatchOwl\\CakeScheduler\\Schedule\\CakeSchedule();\n\n$schedule\n    -\u003erun('/usr/bin/php backup.php')\n    -\u003ebefore(function() { \n        // Do something before the job runs\n     })\n    -\u003edaily()\n    -\u003edescription('Test');\n    \nreturn $schedule;\n```\n\n### After A Job Is Finished\nTo do something after a job is executed, we can use the *after()* hook:\n\nFor example:\n\n```php\n$schedule = new \\WatchOwl\\CakeScheduler\\Schedule\\CakeSchedule();\n\n$schedule\n    -\u003erun('/usr/bin/php backup.php')\n    -\u003eafter(function() { \n        // Do something after the job is finished\n     })\n    -\u003edaily()\n    -\u003edescription('Test');\n    \nreturn $schedule;\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatchowl%2Fcake-scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatchowl%2Fcake-scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatchowl%2Fcake-scheduler/lists"}