Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qsub: get last job id submitted

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"
like image 380
JuanPablo Avatar asked Nov 03 '25 06:11

JuanPablo


1 Answers

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}'
like image 191
Steve Avatar answered Nov 04 '25 18:11

Steve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!