Run a job on a cron schedule

Run a job on a cron schedule

Scheduled jobs differ on every platform. GitHub and GitLab express schedules in YAML; CircleCI and Bitbucket configure them in the UI (Bitbucket) or as a separate workflow trigger (CircleCI).

Conversion notes

  • Bitbucket schedules are configured at Pipelines → Schedules in the repository UI — they cannot be expressed in bitbucket-pipelines.yml.

Side-by-side implementation

GitHub Actions
name: nightly
on:
  schedule:
    - cron: '0 3 * * *'
  workflow_dispatch: {}
jobs:
  job:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/nightly.sh
GitLab CI
# Configure the schedule in CI/CD → Schedules; this job runs on the schedule trigger.
nightly:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
  script:
    - ./scripts/nightly.sh
CircleCI
version: 2.1

jobs:
  nightly:
    docker: [{ image: cimg/base:stable }]
    steps:
      - checkout
      - run: ./scripts/nightly.sh

workflows:
  nightly:
    triggers:
      - schedule:
          cron: '0 3 * * *'
          filters:
            branches:
              only: [main]
    jobs: [nightly]
Bitbucket Pipelines
# Bitbucket schedules are configured at Pipelines → Schedules in the repo UI.
image: ubuntu:22.04
pipelines:
  custom:
    nightly:
      - step:
          name: nightly
          script:
            - ./scripts/nightly.sh

Related Tools