Archive

Archive for the ‘SGE’ Category

Remember my name ?

July 19, 2012 Leave a comment

Some SGE options looks apparently useless, but with a second thought turn out to be very powerful. -N is one of such an option This post will try to exemplify the benefit of giving name to your job.

Usage :

To give a name to your job, you just need to add -N Name to qsub, thus to give the name Job1 to a script just type :

qsub -N Job1 Job.sh

…. and that ‘s it ! Ok let’s put it now in a working context.

Usefulness of  -N  : situation 1

Suppose, you submit every  month the same shell script, let say “GenomicEvaluation.sh”. If you submit your job with the same name name every month, with the following command


qsub -N GenomicEvaluation GenomicEvaluation.sh

Then, a simple command as :

qacct -j GenomicEvaluation | gawk '{if($1 ~ "start_time"){$1="";printf "%s , ",$0}; if($1 ~ "maxvmem"){print $2}}'  >MemConsumption.csv

Would create a file reporting the  evolution over time of the memory needed for your job !

Usefulness of  -N  : situation 2

Suppose you have 3 scripts, Job1.sh, Job2.sh and FinalJob.sh, and you don’t want FinalJob.sh to start before the end of the two first scripts. The trick is then to submit your two first with explanatory name.

qsub -N Job1 Job1.sh
qsub -N Job2 Job2.sh

And then submit FinalJob.sh but this time with the -hold_jid option followed by the two first job names

qsub -N FinalJob -hold_jid Job1,Job2   FinalJob.sh

Nice isn’t it ?

In both case, remember that JobID are given by SGE (in order of submission and based on the indication of jobseqnum in ${SGE_ROOT}/default/spool/qmaster) so they can hardly be predicted, whereas name are totally under control !

Usefulness of  -N  : situation 3

A more trivial use of -N can be to pass a variable to your script, in fact within the job environment the name you gave at submission will be assign to JOB_NAME environment variable.

Categories: Linux, SGE, Shell Tags: