Skip to content

Environment-based activation of cron jobs #1

Description

@dmekhov

It would be very helpful to be able to enable or disable cron jobs based on the current environment or specific environment variable values.
(e.g., Laravel’s Scheduler via ->environment() or ->when() methods).

You might want certain jobs to run only in production or to disable certain jobs in development/testing.

Additionally, being able to toggle a job via an environment variable (e.g., CRON_TASK1_ENABLED=0).

cron:
  jobs:
    - name: "cache-warmup"
      command: "php artisan cache:warmup"
      schedule: "0 */6 * * *"
      # Conditionally enabled via an env variable
      enabled_if_env: "CRON_TASK1_ENABLED=1"
      # Or only on production environment
      enabled_if_env: ["production"] # alias for `APP_ENV=production`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions