Created
July 21, 2022 22:16
-
-
Save varontron/b33d0bd20206ec7bac1e51eaa964213e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# The script will iterate through the queues and terminate any jobs in these queues with any of the following states: | |
# SUBMITTED PENDING RUNNABLE STARTING RUNNING | |
# Requirements: | |
# valid ~/.aws/credentials | |
# aws cli installed | |
# Usage: | |
# pass space-delimited quoted string of queue names as argument to script, e.g., | |
# terminateJobs.zsh "my-nextflow-head-queue my-nextflow-small-process-queue my-nf-large-process-queue" | |
# | |
queues=($1) | |
for queue in ${=queues} | |
do | |
for state in SUBMITTED PENDING RUNNABLE STARTING RUNNING | |
do | |
for job in $(aws batch list-jobs --job-queue $queue --job-status $state --output text --query 'jobSummaryList[*].[jobId]') | |
do | |
echo -ne "Stopping job $job in state $state\t" | |
aws batch terminate-job --reason "Terminating job." --job-id $job && echo "Done." || echo "Failed." | |
done | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment