1

I am using sun grid engine 6.2u5 version . where requirement is when I submit job on using qsub command on completion job i want to run some script(bash scripts).

how can i use -notify option or any other way to track job completion and after completion execute script.

Thanks

Swapnil Sonawane
  • 1,445
  • 3
  • 22
  • 37

3 Answers3

2

I think hold_jid is what you're looking for:

qsub -hold_jid jobToWaitFor bashScript

You can also specify multiple jobs to wait for by separating them with commas.

Memento Mori
  • 3,327
  • 2
  • 22
  • 29
  • Thanks @Memento Mori I have tried same. when I run command like qsub -hold_jid test.sh script.sh then it submit and execure script.sh as job and nothing happen with test.sh – Swapnil Sonawane Mar 14 '13 at 09:58
  • @SwapnilSonawane My fault, I should have specified! That command does not actually submit the 'jobToWaitFor'. Probably what's happening is that the system checked to see if jobToWaitFor was running, saw it wasn't, and submitted the bash script. So for it to work the way you want, you would have to submit the 'jobToWaitFor' previously and then run the command in my answer. You could make a script which submits the job and then this command. – Memento Mori Mar 14 '13 at 10:06
  • Thanks @Memento Mori it working fine. once again thanks. do you know how to use -notify or catch signals (SIGUSR1, SIGUSR2)send by sge ? – Swapnil Sonawane Mar 14 '13 at 10:19
  • can we pass variable or any value from first job to second using above commands – Swapnil Sonawane Mar 14 '13 at 10:21
  • @SwapnilSonawane That I am not sure about. I suppose since you know the first job must finish before the second can begin you could write something to a file which could be read by the second program. I'm not sure if they could communicate directly though, that's a situation I haven't come across. The only thing I know about notify is that it sends SIGUSR2 to the running program. That's for giving the program a warning before it will be cancelled, I'm not sure if that's what you want to do. But this page has a bit of info on it https://www.clumeq.ca/wiki/index.php/Using_SGE – Memento Mori Mar 14 '13 at 10:27
0

There is a dedicated option for that in the queue configuration. You can set a "Prolog" or "Epilog" script that will be executed before and after the job respectively. See man queue_conf or http://gridscheduler.sourceforge.net/htmlman/htmlman5/queue_conf.html.

Yves K
  • 1
  • 1
0

If '-hold_jid' is not available on your system, you can try '-depend', but it requires two commands.

>> qsub script_a.sh
555.server.domain.com 

>> qsub -W depend=afterok:555.server.address.com script_b.sh
556.server.domain.com

Check this answer to wait on the completion of multiple jobs.

Community
  • 1
  • 1
skytaker
  • 4,159
  • 1
  • 21
  • 31