sbatch | grep yourname | grep job_name | awk '{print "scancel " $1}' > jobs.cancel then and !#/bin/bash to first jobs.cancel file, and then bash jobs.cancel