Skip to content

Instantly share code, notes, and snippets.

@jaklinger
Created May 21, 2018 10:58
Show Gist options
  • Save jaklinger/788df922b1e9cfb848ce1f8f1d31b38f to your computer and use it in GitHub Desktop.
Save jaklinger/788df922b1e9cfb848ce1f8f1d31b38f to your computer and use it in GitHub Desktop.
Terminate all RUNNING AND RUNNABLE processes in boto3
import time
import boto3
client = boto3.client('batch')
i = 0
for job in client.list_jobs(jobQueue="HighPriority", jobStatus="RUNNABLE")["jobS
ummaryList"]:
i+=1
print(job["jobId"])
client.terminate_job(jobId=job["jobId"], reason="Too slow")
time.sleep(0.2)
print(i)
i=0
for job in client.list_jobs(jobQueue="HighPriority", jobStatus="RUNNING")["jobSu
mmaryList"]:
i+=1
print(job["jobId"])
client.terminate_job(jobId=job["jobId"], reason="Too slow")
time.sleep(0.2)
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment