Under normal conditions, jobs run periodically and auto-terminate once their task is completed. In some cases, you may want to stop all scheduled jobs.
For more information on scheduled jobs, please review the Create, run, and manage Databricks Jobs (AWS | Azure | GCP) documentation.
This article provides sample code that you can use to stop all of your scheduled jobs.
Instructions
Use the following sample code to stop all of your scheduled jobs in the workspace.
- Copy and paste the sample code into a notebook cell.
- Replace the <workspace-domain-without-trailing-backslash> and <personal-access-token> values with ones specific to your workspace.
- Run the cell to stop all of your scheduled jobs in the workspace.
%python import requests import json shard_url= "<workspace-domain-without-trailing-backslash>" access_token= "<personal-access-token>" flag = 0 headers_auth = { 'Authorization': f'Bearer {access_token}' } jobs_list = requests.request("GET", job_list_url, headers=headers_auth).json() for job in jobs_list['jobs']: if "schedule" in job['settings']: if job['settings']['schedule']['pause_status'] == "UNPAUSED": flag += 1 schedule = job['settings']['schedule'] schedule['pause_status'] = "PAUSED" job_name = job['settings']['name'] job_id = job['job_id'] payload_pause_schedule = json.dumps({ "job_id": job['job_id'], "new_settings": { "schedule": schedule } }) response = requests.request("POST", job_update_url, headers = headers_auth, data = payload_pause_schedule) print("Pausing job ",job_id) if flag == 0: print("No jobs to be paused")