For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > May 2004 > how to get the status from scripts running in the background









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to get the status from scripts running in the background
Ryan Gaffuri

2004-05-24, 12:35 pm

I need to:

1. run several scripts concurrently
2. wait until they are done
3. get the exit status
4. If one fails, then I need to do some error handling.
5. its also redirecting to nohup.out

nohup run_sql $ERROR_MSG_OPTION -u $LOGIN_FILE_NAME $SQL_SCRIPT1 2>&1
> sql_script1.log;

message "$? $SQL_SCRIPT1" $STATUS_FILE &
nohup run_sql $ERROR_MSG_OPTION -u $LOGIN_FILE_NAME $SQL_SCRIPT2 2>&1
> sql_script1.log;

message "$? SQL_SCRIPT2" $STATUS_FILE &
wait


$STATUS_FILE is just a file, I need to grep for errors. This works,
but it does not run concurrently in the background and I get
'redirected to nohup.out'

this is korn shell.
Barry Margolin

2004-05-24, 6:35 pm

In article <1efdad5b.0405240726.3c6997d0@posting.google.com>,
rgaffuri@cox.net (Ryan Gaffuri) wrote:

> I need to:
>
> 1. run several scripts concurrently
> 2. wait until they are done
> 3. get the exit status
> 4. If one fails, then I need to do some error handling.
> 5. its also redirecting to nohup.out


If you use "wait <pid>", it waits for that background process to finish,
and the exit status of this command is the exit status of the background
process.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com