You can use cron jobs to execute pipelines on time-based schedules. You can create and manage cron jobs from the repository Settings screen, or using the command line tools.
Example creates a cron job named hourly using a cron expression:
$ drone cron create "octocat/hello-world" "hourly" "0 0 * * * *"
Example creates a cron job named deploy using a pre-defined schedule:
$ drone cron create "octocat/hello-world" "deploy" @nightly
The cron expression represents a set of times, using 6 space-separated fields, including seconds.
|Field name||Mandatory?||Allowed values||Allowed characters|
|Seconds||Yes||0-59||* / , -|
|Minutes||Yes||0-59||* / , -|
|Hours||Yes||0-23||* / , -|
|Day of month||Yes||1-31||* / , - ?|
|Month||Yes||1-12 or JAN-DEC||* / , -|
|Day of week||Yes||0-6 or SUN-SAT||* / , - ?|
Use one of several pre-defined schedules in place of a cron expression.
|@yearly||0 0 0 1 1 *||Run once a year, midnight, Jan. 1st|
|@monthly||0 0 0 1 * *||Run once a month, midnight, first of month|
|@weekly||0 0 0 * * 0||Run once a week, midnight between Sat/Sun|
|@daily||0 0 0 * * *||Run once a day, midnight|
|@hourly||0 0 * * * *||Run once an hour, beginning of hour|
The current implementation calculates the execution time based on UTC as opposed to local time.
The cron scheduler is approximate and executes jobs within a one hour window of the scheduled execution time. This prevents users from creating high frequency jobs and overloading the system, but as a result, means cron scheduling has less accurate timing.
You can reduce the one hour window and increase scheduler accuracy by changing the server’s cron interval setting.Customize the Cron Interval
The cron scheduler executes all matching pipelines and steps defined in your yaml configuration file. See the pipeline configuration documentation to limit cron execution of pipelines and pipeline steps:
Limit Pipeline Execution Limit Pipeline Step Execution