[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: launching jobs in a combined serial parallel way



Hello,

On Mon, Jun 22, 2009 at 08:17:44PM -0400, Kamaraju S Kusumanchi wrote:
> Currently I have a shell script that works as below.
> 1) launch proga, progb in the background using nohup.
> 2) Ask proga, progb to write a file when they finish.
> 3) Every five minutes check if these files are present. If they are
>    present, launch progc.
> 
> This gets me going for now. But it looks terribly inefficient. I would
> appreciate if someone can provide a better solution.

Douglas A. Tutty <dtutty@vianet.ca>:
] While you may think its terribly inefficient, it isn't really. A fancy
] "wait" function is just polling anyway, you're just making it overt.
] You also have the ability to have proga and progb only touch the file
] if they complete successfully. If you merely wait until their ps dis-
] appears, you don't know if they crashed or properly completed.

Agreed. The original solution is, in my view, perfectly clean and fine.
It's simple, and simple is good. Another problem with a ps(1)-monitoring
solution, besides the one Douglas points out above, is that it doesn't
scale; a script that uses ps(1) can't be run concurrently in multiple
directories, should your requirements eventually expand to include that
in future. Your solution, Kamaraju, can.

Nota bene: Just as in recursion one tests for the stopping condition
first, at the top of the function, I presume you're remembering to test
for the existence of these semaphore files before launching proga and
progb, and "doing the right thing" (however you define that, e.g. not
proceeding at all, or alternatively just removing them and proceeding)
if they're already there.

Cheers,
Eric
--
"The great French Marshal Lyautey once asked his gardener to plant a
tree. The gardener objected that the tree was slow-growing and would not
reach maturity for 100 years. The marshal replied: ''In that case, there
is no time to lose, plant it this afternoon.''" --John F. Kennedy

Eric De Mund   |  Y!: ead0002
ead@ixian.com  |  ICQ: 811788


Reply to: