{"id":13579039,"url":"https://github.com/zenstruck/schedule-bundle","last_synced_at":"2025-05-14T14:08:29.143Z","repository":{"id":40332671,"uuid":"232883972","full_name":"zenstruck/schedule-bundle","owner":"zenstruck","description":"Schedule Cron jobs (commands/callbacks/bash scripts) within your Symfony application.","archived":false,"fork":false,"pushed_at":"2025-04-27T22:34:08.000Z","size":1576,"stargazers_count":392,"open_issues_count":15,"forks_count":20,"subscribers_count":11,"default_branch":"1.x","last_synced_at":"2025-04-27T23:25:39.466Z","etag":null,"topics":["cron","schedule","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenstruck.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":"kbond"}},"created_at":"2020-01-09T19:07:53.000Z","updated_at":"2025-04-27T22:34:11.000Z","dependencies_parsed_at":"2023-12-13T01:47:40.674Z","dependency_job_id":"e011bcf2-5f16-4a94-a43a-eaa863ab2089","html_url":"https://github.com/zenstruck/schedule-bundle","commit_stats":{"total_commits":215,"total_committers":12,"mean_commits":"17.916666666666668","dds":0.06511627906976747,"last_synced_commit":"66f22d465d5fef0faed70f4e326c2e8a430acf13"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Fschedule-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Fschedule-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Fschedule-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Fschedule-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenstruck","download_url":"https://codeload.github.com/zenstruck/schedule-bundle/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159800,"owners_count":22024564,"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":["cron","schedule","symfony","symfony-bundle"],"created_at":"2024-08-01T15:01:36.004Z","updated_at":"2025-05-14T14:08:29.124Z","avatar_url":"https://github.com/zenstruck.png","language":"PHP","funding_links":["https://github.com/sponsors/kbond"],"categories":["PHP"],"sub_categories":[],"readme":"# The ScheduleBundle\n\n[![CI](https://github.com/zenstruck/schedule-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/zenstruck/schedule-bundle/actions/workflows/ci.yml)\n[![Code Coverage](https://codecov.io/gh/zenstruck/schedule-bundle/branch/master/graph/badge.svg?token=SZE54O8YST)](https://codecov.io/gh/zenstruck/schedule-bundle)\n[![Latest Version](https://img.shields.io/packagist/v/zenstruck/schedule-bundle.svg)](https://packagist.org/packages/zenstruck/schedule-bundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/zenstruck/schedule-bundle.svg)](https://packagist.org/packages/zenstruck/schedule-bundle)\n\nSchedule Cron jobs (commands/callbacks/bash scripts) within your Symfony\napplication. Most applications have jobs that need to run at specific intervals.\nThis bundle enables you to define these jobs in your code. Job definitions (tasks)\nare version controlled like any other feature of your application. A single Cron\nentry (`php bin/console schedule:run`) on your server running every minute executes due\ntasks.\n\nThe inspiration and some of the API/code for this Bundle comes from [Laravel's\nTask Scheduling feature](https://laravel.com/docs/master/scheduling).\n\n1. [Installation](#installation)\n2. [Quick Start](#quick-start)\n3. [Defining the Schedule](doc/define-schedule.md)\n    1. [ScheduleBuilder Service](doc/define-schedule.md#schedulebuilder-service)\n    2. [Your Kernel](doc/define-schedule.md#your-kernel)\n    3. [Bundle Configuration](doc/define-schedule.md#bundle-configuration)\n    4. [`AsScheduledTask` Attribute](doc/define-schedule.md#asscheduledtask-attribute)\n    5. [Self-Scheduling Commands](doc/define-schedule.md#self-scheduling-commands)\n    6. [Timezone](doc/define-schedule.md#timezone)\n    7. [Schedule Extensions](doc/define-schedule.md#schedule-extensions)\n        1. [Filters](doc/define-schedule.md#filters)\n        2. [Callbacks](doc/define-schedule.md#callbacks)\n        3. [Ping Webhook](doc/define-schedule.md#ping-webhook)\n        4. [Email On Failure](doc/define-schedule.md#email-on-failure)\n        5. [Notify On Failure](doc/define-schedule.md#notify-on-failure)\n        6. [Run on Single Server](doc/define-schedule.md#run-on-single-server)\n        7. [Limit to specific environment(s)](doc/define-schedule.md#limit-to-specific-environments)\n4. [Defining Tasks](doc/define-tasks.md)\n    1. [Task Types](doc/define-tasks.md#task-types)\n        1. [CommandTask](doc/define-tasks.md#commandtask)\n        2. [CallbackTask](doc/define-tasks.md#callbacktask)\n        3. [ProcessTask](doc/define-tasks.md#processtask)\n        3. [MessageTask](doc/define-tasks.md#messagetask)\n        4. [PingTask](doc/define-tasks.md#pingtask)\n        5. [CompoundTask](doc/define-tasks.md#compoundtask)\n    2. [Task Description](doc/define-tasks.md#task-description)\n    3. [Frequency](doc/define-tasks.md#frequency)\n        1. [Cron Expression](doc/define-tasks.md#cron-expression)\n        2. [Fluent Expression Builder](doc/define-tasks.md#fluent-expression-builder)\n        3. [Hashed Cron Expression](doc/define-tasks.md#hashed-cron-expression)\n    4. [Task ID](doc/define-tasks.md#task-id)\n    5. [Timezone](doc/define-tasks.md#timezone)\n    6. [Task Extensions](doc/define-tasks.md#task-extensions)\n        1. [Filters](doc/define-tasks.md#filters)\n        2. [Callbacks](doc/define-tasks.md#callbacks)\n        3. [Ping Webhook](doc/define-tasks.md#ping-webhook)\n        4. [Email Output](doc/define-tasks.md#email-output)\n        4. [Notify Output](doc/define-tasks.md#notify-output)\n        5. [Prevent Overlap](doc/define-tasks.md#prevent-overlap)\n        6. [Run on Single Server](doc/define-tasks.md#run-on-single-server)\n        7. [Between](doc/define-tasks.md#between)\n5. [Running the Schedule](doc/run-schedule.md)\n    1. [Cron Job on Server](doc/run-schedule.md#cron-job-on-server)\n    2. [Symfony Cloud](doc/run-schedule.md#symfony-cloud)\n    3. [Alternatives](doc/run-schedule.md#alternatives)\n    4. [Force Run](doc/run-schedule.md#force-run)\n    5. [Dealing with Failures](doc/run-schedule.md#dealing-with-failures)\n    6. [Ensuring Schedule is Running](doc/run-schedule.md#ensuring-the-schedule-is-running)\n    7. [Disable Schedule during Deploy](doc/run-schedule.md#disable-schedule-during-deploy)\n6. [CLI Commands](doc/cli-commands.md)\n    1. [schedule:list](doc/cli-commands.md#schedulelist)\n    2. [schedule:run](doc/cli-commands.md#schedulerun)\n7. [Extending](doc/extending.md)\n    1. [Custom Tasks](doc/extending.md#custom-tasks)\n    2. [Custom Extensions](doc/extending.md#custom-extensions)\n    3. [Events](doc/extending.md#events)\n8. [Full Configuration Reference](#full-configuration-reference)\n\n## Installation\n\n```console\ncomposer require zenstruck/schedule-bundle\n```\n\n*If not using Symfony Flex, be sure to enable the bundle.*\n\n## Quick Start\n\n1. Add your schedule service (assumes *autowire* and *autoconfiguration* enabled):\n\n    ```php\n    // src/Schedule/AppScheduleBuilder.php\n\n    namespace App\\Schedule;\n\n    use Zenstruck\\ScheduleBundle\\Schedule;\n    use Zenstruck\\ScheduleBundle\\Schedule\\ScheduleBuilder;\n\n    class AppScheduleBuilder implements ScheduleBuilder\n    {\n        public function buildSchedule(Schedule $schedule): void\n        {\n            $schedule\n                -\u003etimezone('UTC')\n                -\u003eenvironments('prod')\n            ;\n\n            $schedule-\u003eaddCommand('app:send-weekly-report --detailed')\n                -\u003edescription('Send the weekly report to users.')\n                -\u003esundays()\n                -\u003eat(1)\n            ;\n\n            // ...\n        }\n    }\n    ```\n\n2. List your tasks to diagnose any problems:\n\n    ```console\n    php bin/console schedule:list\n    ```\n\n3. Add the following Cron job on your server running every minute:\n\n    ```\n    * * * * * cd /path-to-your-project \u0026\u0026 php bin/console schedule:run \u003e\u003e /dev/null 2\u003e\u00261\n    ```\n\nSee [Defining the Schedule](doc/define-schedule.md) and [Defining Tasks](doc/define-tasks.md)\nfor more options.\n\n## Full Configuration Reference\n\n```yaml\nzenstruck_schedule:\n\n    # The LockFactory service to use for the without overlapping extension\n    without_overlapping_lock_factory: null # Example: lock.default.factory\n\n    # The LockFactory service to use for the single server extension - be sure to use a \"remote store\" (https://symfony.com/doc/current/components/lock.html#remote-stores)\n    single_server_lock_factory: null # Example: lock.redis.factory\n\n    # The HttpClient service to use\n    http_client:          null # Example: http_client\n\n    # The default timezone for tasks (override at task level), null for system default\n    timezone:             null # Example: America/New_York\n\n    messenger:\n        enabled:              false\n\n        # The message bus to use\n        message_bus:          message_bus\n\n    mailer:\n        enabled:              false\n\n        # The mailer service to use\n        service:              mailer\n\n        # The default \"from\" email address (use if no mailer default from is configured)\n        default_from:         null\n\n        # The default \"to\" email address (can be overridden by extension)\n        default_to:           null\n\n        # The prefix to use for email subjects (use to distinguish between different application schedules)\n        subject_prefix:       null # Example: \"[Acme Inc Website]\"\n\n    notifier:\n        enabled:              false\n\n        # The notifier service to use\n        service:              notifier\n\n        # The default channel (can use a string, or array of channels)\n        default_channel:      null\n\n        # The default email address for email notifications\n        default_email:        null\n\n        # The default phone number for SMS notifications (can be overridden by extension)\n        default_phone:        null\n\n        # The prefix to use for notification subjects (use to distinguish between different application schedules)\n        subject_prefix:       null # Example: \"[Acme Inc Website]\"\n\n    schedule_extensions:\n\n        # Set the environment(s) you only want the schedule to run in.\n        environments:         [] # Example: [prod, staging]\n\n        # Run schedule on only one server\n        on_single_server:\n            enabled:              false\n\n            # Maximum expected lock duration in seconds\n            ttl:                  3600\n\n        # Send email if schedule fails (alternatively enable by passing a \"to\" email)\n        email_on_failure:\n            enabled:              false\n\n            # Email address to send email to (leave blank to use \"zenstruck_schedule.mailer.default_to\")\n            to:                   null\n\n            # Email subject (leave blank to use extension default)\n            subject:              null\n\n        # Send notification if schedule fails (alternatively enable by passing a channel)\n        notify_on_failure:\n            enabled:              false\n\n            # Channel to send notification to (leave blank to use \"zenstruck_schedule.notifier.default_channel\")\n            channel:              null\n\n            # Notification subject (leave blank to use extension default)\n            subject:              null\n\n            # Email address for email notifications  (leave blank to use extension default)\n            email:                null\n\n            # Phone number for SMS notifications (leave blank to use extension default)\n            phone:                null\n\n        # Ping a url before schedule runs (alternatively enable by passing a url)\n        ping_before:\n            enabled:              false\n\n            # The url to ping\n            url:                  ~ # Required\n\n            # The HTTP method to use\n            method:               GET\n\n            # See HttpClientInterface::OPTIONS_DEFAULTS\n            options:              []\n\n        # Ping a url after schedule runs (alternatively enable by passing a url)\n        ping_after:\n            enabled:              false\n\n            # The url to ping\n            url:                  ~ # Required\n\n            # The HTTP method to use\n            method:               GET\n\n            # See HttpClientInterface::OPTIONS_DEFAULTS\n            options:              []\n\n        # Ping a url if the schedule successfully ran (alternatively enable by passing a url)\n        ping_on_success:\n            enabled:              false\n\n            # The url to ping\n            url:                  ~ # Required\n\n            # The HTTP method to use\n            method:               GET\n\n            # See HttpClientInterface::OPTIONS_DEFAULTS\n            options:              []\n\n        # Ping a url if the schedule failed (alternatively enable by passing a url)\n        ping_on_failure:\n            enabled:              false\n\n            # The url to ping\n            url:                  ~ # Required\n\n            # The HTTP method to use\n            method:               GET\n\n            # See HttpClientInterface::OPTIONS_DEFAULTS\n            options:              []\n    tasks:\n\n        # Example:\n        -\n            task:                send:sales-report --detailed\n            frequency:           '0 * * * *'\n            description:         Send sales report hourly\n            without_overlapping: ~\n            only_between:        9-17\n            ping_on_success:     https://example.com/hourly-report-health-check\n            email_on_failure:    sales@example.com\n            notify_on_failure:   chat/slack\n\n        # Prototype\n        -\n\n            # Defaults to CommandTask, prefix with \"bash:\" to create ProcessTask, prefix url with \"ping:\" to create PingTask, pass array of commands to create CompoundTask (optionally keyed by description)\n            task:                 ~ # Required, Example: \"my:command arg1 --option1=value\", \"bash:/bin/my-script\" or \"ping:https://example.com\"\n\n            # Cron expression\n            frequency:            ~ # Required, Example: '0 * * * *'\n\n            # Task description\n            description:          null\n\n            # The timezone for this task, null for system default\n            timezone:             null # Example: America/New_York\n\n            # Prevent task from running if still running from previous run\n            without_overlapping:\n                enabled:              false\n\n                # Maximum expected lock duration in seconds\n                ttl:                  86400\n\n            # Only run between given times (alternatively enable by passing a range, ie \"9:00-17:00\"\n            only_between:\n                enabled:              false\n                start:                ~ # Required, Example: 9:00\n                end:                  ~ # Required, Example: 17:00\n\n            # Skip when between given times (alternatively enable by passing a range, ie \"17:00-06:00\"\n            unless_between:\n                enabled:              false\n                start:                ~ # Required, Example: 17:00\n                end:                  ~ # Required, Example: 06:00\n\n            # Ping a url before task runs (alternatively enable by passing a url)\n            ping_before:\n                enabled:              false\n\n                # The url to ping\n                url:                  ~ # Required\n\n                # The HTTP method to use\n                method:               GET\n\n                # See HttpClientInterface::OPTIONS_DEFAULTS\n                options:              []\n\n            # Ping a url after task runs (alternatively enable by passing a url)\n            ping_after:\n                enabled:              false\n\n                # The url to ping\n                url:                  ~ # Required\n\n                # The HTTP method to use\n                method:               GET\n\n                # See HttpClientInterface::OPTIONS_DEFAULTS\n                options:              []\n\n            # Ping a url if the task successfully ran (alternatively enable by passing a url)\n            ping_on_success:\n                enabled:              false\n\n                # The url to ping\n                url:                  ~ # Required\n\n                # The HTTP method to use\n                method:               GET\n\n                # See HttpClientInterface::OPTIONS_DEFAULTS\n                options:              []\n\n            # Ping a url if the task failed (alternatively enable by passing a url)\n            ping_on_failure:\n                enabled:              false\n\n                # The url to ping\n                url:                  ~ # Required\n\n                # The HTTP method to use\n                method:               GET\n\n                # See HttpClientInterface::OPTIONS_DEFAULTS\n                options:              []\n\n            # Send email after task runs (alternatively enable by passing a \"to\" email)\n            email_after:\n                enabled:              false\n\n                # Email address to send email to (leave blank to use \"zenstruck_schedule.mailer.default_to\")\n                to:                   null\n\n                # Email subject (leave blank to use extension default)\n                subject:              null\n\n            # Send email if task fails (alternatively enable by passing a \"to\" email)\n            email_on_failure:\n                enabled:              false\n\n                # Email address to send email to (leave blank to use \"zenstruck_schedule.mailer.default_to\")\n                to:                   null\n\n                # Email subject (leave blank to use extension default)\n                subject:              null\n\n            # Send notification after task runs (alternatively enable by passing a channel)\n            notify_after:\n                enabled:              false\n\n                # Channel to send notification to (leave blank to use \"zenstruck_schedule.notifier.default_channel\")\n                channel:              null\n\n                # Notification subject (leave blank to use extension default)\n                subject:              null\n\n                # Email to send email notifications to (leave blank to use extension default)\n                email:                null\n\n                # Phone number for SMS notifications (leave blank to use extension default)\n                phone:                null\n\n            # Send email if task fails (alternatively enable by passing a \"to\" email)\n            notify_on_failure:\n                enabled:              false\n\n                # Channel to send notification to (leave blank to use \"zenstruck_schedule.notifier.default_channel\")\n                channel:              null\n\n                # Notification subject (leave blank to use extension default)\n                subject:              null\n\n                # Email to send email notifications to (leave blank to use extension default)\n                email:                null\n\n                # Phone number for SMS notifications (leave blank to use extension default)\n                phone:                null\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenstruck%2Fschedule-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenstruck%2Fschedule-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenstruck%2Fschedule-bundle/lists"}