Run jobs on a schedule or continuously

You can run your Azure Databricks job periodically with the Scheduled trigger type or ensure there's always an active run of the job with the Continuous trigger type.

You can use a schedule to automatically run your Azure Databricks job at specified times and periods. You can define a simple schedule to run your job periodically or an advanced schedule that uses cron to define specific times for a periodic schedule. With an advanced schedule, you can also select a time zone for your schedule. You can pause a scheduled job at any time.

When you run your job with the continuous trigger, Azure Databricks Jobs ensures there is always one active run of the job. A new job run starts after the previous run completes successfully or with a failed status, or if there is no instance of the job currently running.

Add a job schedule

The Scheduled trigger type has two options:

  • Define a basic schedule to run a job periodically based on a specified time unit and interval. For example, schedule a job to run every twelve hours, starting at the time when the job is first run.
  • Define an advanced schedule that offers more control over the period, time, and time zone to run the job.

To define a schedule for the job:

  1. In the sidebar, click Workflows.
  2. In the Name column on the Jobs tab, click the job name.
  3. In the Job details panel, click Add trigger.
  4. In Trigger type select Scheduled.
  5. In Schedule type, select Simple or Advanced.
    1. Simple: Specify an interval and unit of time to run the job.
    2. Advanced: Specify the period, starting time, and time zone. Optionally select the Show Cron Syntax checkbox to display and edit the schedule in Quartz Cron Syntax.
  6. Click Save.

You can also schedule a notebook job directly in the notebook UI.

Note

  • Azure Databricks enforces a minimum interval of 10 seconds between subsequent runs triggered by the schedule of a job regardless of the seconds configuration in the cron expression.
  • You can choose a time zone that observes daylight saving time or UTC. If you select a time zone that observes daylight saving time, an hourly job will be skipped or might appear to be delayed by an hour or two when daylight saving time begins or ends. To run at every hour (absolute time), choose UTC.
  • The job scheduler is not intended for low-latency jobs. Due to network or cloud issues, job runs might occasionally be delayed up to several minutes. In these situations, scheduled jobs run immediately upon service availability.

Pause and resume a job schedule

To pause a job, click Pause in the Job details panel.

To resume a paused job schedule, click Resume.

Run a continuous job

  1. In the sidebar, click Workflows.
  2. In the Name column on the Jobs tab, click the job name.
  3. Click Add trigger in the Job details panel, click Add trigger in the Job details panel, select Continuous in Trigger type, and click Save.

To stop a continuous job, click Blue Down Caret next to Run Now and click Stop.

Note

  • There can be only one running instance of a continuous job.
  • There is a small delay between a run finishing and a new run starting. This delay should be less than 60 seconds.
  • You cannot use task dependencies with a continuous job.
  • You cannot use retry policies with a continuous job. Instead, continuous jobs use exponential backoff to manage job run failures.
  • Selecting Run now on a continuous job that is paused triggers a new job run. If the job is unpaused, an exception is thrown.
  • To have your continuous job pick up a new job configuration, cancel the existing run and then a new run automatically starts. You can also click Restart run to restart the job run with the updated configuration.

How are failures handled for continuous jobs?

Azure Databricks Jobs uses an exponential backoff scheme to manage continuous jobs with multiple consecutive failures. Exponential backoff allows continuous jobs to run without pausing and return to a healthy state when recoverable failures occur.

When a continuous job exceeds the allowable threshold for consecutive failures, the following describes how subsequent job runs are managed:

  1. The job is restarted after a retry period set by the system.
  2. If the next job run fails, the retry period is increased, and the job is restarted after this new retry period.
    1. For each subsequent job run failure, the retry period is increased again, up to a maximum retry period set by the system. After reaching the maximum retry period, the job continues to be retried using the maximum retry period. There is no limit on the number of retries for a continuous job.
    2. If the job run completes successfully and starts a new run, or if the run exceeds a threshold without failure, the job is considered healthy, and the backoff sequence resets.

You can restart a continuous job in the exponential backoff state in the Jobs UI or by passing the job ID to the POST /api/2.1/jobs/run-now request in the Jobs 2.1 API or the POST /api/2.0/jobs/run-now request in the Jobs 2.0 API.