doc/ci/pipelines/schedules.md
{{< details >}}
{{< /details >}}
Create pipeline schedules to run pipelines at regular intervals based on cron patterns. Use pipeline schedules for tasks that need to run on a time-based schedule rather than triggered by code changes.
Unlike pipelines triggered by commits or merge requests, scheduled pipelines run independently of code changes. This makes them suitable for tasks that need to happen regardless of development activity, such as keeping deployments current or running periodic maintenance.
Scheduled pipelines stop running when a project or group is marked for deletion.
{{< history >}}
{{< /history >}}
When you create a pipeline schedule, you become the schedule owner. The pipeline runs with your permissions and can access protected environments and use the CI/CD job token based on your access level.
Prerequisites:
.gitlab-ci.yml file must have valid syntax. You can validate your configuration before scheduling.To create a pipeline schedule:
spec:inputs section.
These input values are used every time the scheduled pipeline runs. A schedule can have a maximum of 20 inputs.If the project has reached the maximum number of pipeline schedules, delete unused schedules before adding another.
Prerequisites:
To edit a pipeline schedule:
You can manually run scheduled pipelines once per minute. When you run a scheduled pipeline manually, it uses your permissions instead of the schedule owner's permissions.
To trigger a pipeline schedule immediately instead of waiting for the next scheduled time:
If a pipeline schedule becomes inactive because the original owner is unavailable, you can take ownership.
Scheduled pipelines execute with the permissions of the user who owns the schedule.
Prerequisites:
To take ownership of a schedule:
{{< history >}}
{{< /history >}}
To view the active pipeline schedules that you own across all your projects:
When working with pipeline schedules, you might encounter the following issues.
If a scheduled pipeline status changes to Inactive unexpectedly,
the schedule owner might have been blocked or removed from the project.
Take ownership of the schedule to reactivate it.
To prevent excessive load from too many pipelines starting simultaneously, review and distribute your pipeline schedules:
Run this command to extract and format schedule data:
outfile=/tmp/gitlab_ci_schedules.tsv
sudo gitlab-psql --command "
COPY (SELECT
ci_pipeline_schedules.cron,
ci_pipeline_schedules.cron_timezone,
namespaces.path AS group,
projects.path AS project,
users.email
FROM ci_pipeline_schedules
JOIN projects ON projects.id = ci_pipeline_schedules.project_id
JOIN namespaces ON namespaces.id = projects.namespace_id
JOIN users ON users.id = ci_pipeline_schedules.owner_id
WHERE ci_pipeline_schedules.active = 't'
) TO '$outfile' CSV HEADER DELIMITER E'\t' ;"
sort "$outfile" | uniq -c | sort -n
Review the output to identify popular cron patterns.
For example, many schedules might run at the start of every hour (0 * * * *).
Adjust the schedules to create a staggered cron pattern, especially for large repositories.
For example, instead of multiple schedules running at the start of every hour,
distribute them throughout the hour (5 * * * *, 15 * * * *, 25 * * * *).