Date: Sun, 1 Oct 2000 11:33:57 -0700 From: Alfred Perlstein <bright@wintelcom.net> To: krishna vallapareddy <kvallapareddy@appworx.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: statuses of background jobs in shell scripts Message-ID: <20001001113357.F27736@fw.wintelcom.net> In-Reply-To: <00d801c02bd1$f18b4790$7ac9010a@kvalpareddy_lp.appworx.com>; from kvallapareddy@appworx.com on Sun, Oct 01, 2000 at 02:03:46PM -0400 References: <00d801c02bd1$f18b4790$7ac9010a@kvalpareddy_lp.appworx.com>
next in thread | previous in thread | raw e-mail | index | archive | help
* krishna vallapareddy <kvallapareddy@appworx.com> [001001 11:08] wrote: > Hi, > I would like to know how I can redirect the 'Done x' > messages that you would get if a job were submitted at > the command line to a file. Also, this does not happen > when the job is submitted in a shell script. > My problem is, I need to submit a lot of jobs in the > background in a loop based on a counter that I increment using expr command. > After that I need to > track the statuses of each of these jobs. If the job has > not finished, I could use the wait command but how do I > get the statuses of the jobs that have already finished? > > Any help in this regard is highly appreciated. First off you don't mention which shell you're using, so I'm assuming 'sh' because it's the only shell one should program for. basically: #!/bin/sh (sleep 3 ; echo done; exit 5) & pid=$! echo before wait $pid status=$? echo $pid exited with status $status good luck, -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001001113357.F27736>