qsub: get last job id submitted

1.5k views Asked by At

I use Sun Grid Engine, how I can get the id of the last job submitted with qsub?

currently I use this bash alias

alias lastjob="qstat -u $(whoami) |tail -n1| sed '/LOGIN/d'|cut -d' ' -f1"
1

There are 1 answers

0
Steve On

Ideally, you should capture the job id from the output of the qsub command:

jobid=$(qsub -terse helloworld.sh)

If you need the last job id later after it is submitted, you can use qstat. It looks like your problem with qstat is caused by "cut" delimiters. The qstat output contains multiple spaces before the job id. Try awk instead.

This works for me:

 qstat | tail -n 1 | awk '{print $1}'