bug-bash
[Top][All Lists]
Advanced

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

Re: How to get control from bash script of a batch job


From: Greg Wooledge
Subject: Re: How to get control from bash script of a batch job
Date: Tue, 8 Feb 2011 10:36:18 -0500
User-agent: Mutt/1.4.2.3i

On Mon, Feb 07, 2011 at 09:38:42PM -0800, mauede wrote:
> I launch a Monte Carlo simulation as a batch job from a bash script:
> 
>  exb BEAM_$acc_name $beamin 521icru2 long batch=PBS p=1&

You're launching it in the background.

> I can still get the process id (I think) through the command:
> 
>  exb1_pid=$! 
> 
> I have to launch another simulation which will be given in input  a file
> created by the previous one.
> Can I trust such process ID to wait until the simulation is completed  so as
> I know when to launch the second simulation ?

Why not just *stop* launching it in the background?  That way you'll know
when it's done.

If you absolutely must launch it in the background for some unspecified
reason, then you can use the "wait" command to wait for it to finish.

> My doubt is that all the process control is handled by the batch system PBS.

Public Broadcasting System...?

> If I type "qstat" on a terminal line I get the batch running process ID 
> which is not the same as $!.

I have no idea what qstat is, but if the PID of the running process is not
the same as the PID returned to bash through the $! special parameter,
then what that means is your exb process performed a fork() somewhere along
the line and created a new process.

In which case, your question is probably outside the scope of this mailing
list.

I have a few hints for dealing with evil self-backgrounding processes on
http://mywiki.wooledge.org/ProcessManagement but utlimately the real
answer is typically "fix the program so it stops doing that".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]