0

I am running several jobs on a cluster, however I want cancel multiple jobs based on its name instead of the job id. I read the slurm documentation and I see I can cancel them using scancel -n jobname but instead of doing 1 by 1, i want to mass delete them all at once. the slurm job screen looks like this for job names

spc_2.30
spc_3.20 
spc_3.10 
spc_3.00 
spc_2.40
spc_3.30      
spc_3.20              
spc_3.10  
spc_2.50  
spc_3.40  
      

can someone suggest a method to cancel jobs based on these names in this instance?

3

1 Answer 1

1

To make it reusable I would do it in 2 steps, get the filtered list see below option 1, then feed it to the scancel command, or do it quick and dirty in the other options, not fully tested, sharing my scripts

Option 1: build a cancl script, to filter the jobs and feed it as an srun


#!/bin/bash

#check processes in some mode, for e.g. standby, which matches with our process name
ps T |grep $1 |grep -v 'grep' |grep -v $0 |awk '{print $1}' > /tmp/temp.txt

i=0
if [ $(cat /tmp/temp.txt |wc -l) -eq 0 ];
then
        echo "there are no slurm jobs to kill"
else
#if there are slurm jobs, kill and count them to know how many processes have been killed
while read pid
do
        #scancel <jobid> use this to cancel each job iteratively in blocking mode
        scancel $pid
        echo "Slurm job, $pid killed \n"
        i=$((i+1))
done < /tmp/temp.txt
#show how many Slurm jobs have been killed
echo "$i Slurm jobs killed"
fi
rm /tmp/temp.txt

option 2, is


You can just do job cancel $ scancel jobinXX

option 3, is


I put options for nodes, status, and

squeue --me --nodelist=awsEC200n37a,awsEC200n37b  --states=RUNNING,PENDING --Format=jobid,name --noheader | grep augcl | awk '{print $1}'  | xargs scancel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .