Checking Status of PID


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking Status of PID
# 1  
Old 09-06-2009
Checking Status of PID

I'm developing a script that spawns many background processes that will be executing concurrently and need to check the exit status of each spawned process after it terminates. After starting the background process I can get the pid from $! which I can store in an associative array but how do I check on the status and exit status of the pid? I suppose I should ask if this is even possible?

Thanks,
twk
# 2  
Old 09-06-2009
I know it can be sort of done in ksh. After the wait for all process, the shell-builtin "jobs -nl" will list all stopped or exited jobs and the exit codes. See man ksh. You could e.g. use watchdog subprocesses with a timeout to kill off subprocesses that take too long.
# 3  
Old 09-06-2009
Code:
cmd1 & id1=$!
cmd2 & id2=$!

wait "$id1"; status1=$!
wait "$id2"; status2=$!

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with finding the exit status of a 'nohup' command using 'PID'.

Hello All, I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command. 1.The fifty scripts are stored in a separate file. 2.In a master script, i'm reading every line of the file through loop and executing... (4 Replies)
Discussion started by: SriRamKrish
4 Replies

2. SCO

PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200

Hi to all, I hope that you can help me with this... SCO Unix 5.0.5, old mashine Pentium III x86, SCSI HDD 36.4 Gb PANIC: exit – Cannot exec /etc/init (PID 1), status 0x00000200 Cannot dump 49055 pages to dumpdev hd (1/41) : space for only 48640 pages Dump not completed Safe to Power Off... (1 Reply)
Discussion started by: lakicevic
1 Replies

3. Shell Programming and Scripting

Checking directory status

Can I use -ctime/-mtime to verify if a particular directory has been updated or not? I don't care about number of days. I just want to perform some operations only if the folder is modified (or it's metadata is modified), i.e. some files are added to the directory. This thread has a more... (1 Reply)
Discussion started by: Pramit
1 Replies

4. Shell Programming and Scripting

checking the status of sendmail

Hi All, I like to check the status of sendmail and take the appropriate action based on success / failure etc. I have gone through one of the thread where a suggestion is made to use RC for return code Following is the code: ================================== #!/usr/bin/bash export... (0 Replies)
Discussion started by: tmanda
0 Replies

5. SCO

PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200.

hi all when ever i power on my sco server it give me the message:PANIC: exit - cannot exec /etc/init (PID 1), status 0*00000200. its not booting. any help?? (1 Reply)
Discussion started by: Danish
1 Replies

6. Shell Programming and Scripting

Checking the status of mail sent.

Hi, Is there any way to check the status of the mail sent or not.e.g mail -s "Error Message" abc@xyz.com <aaa/bbb/data.txt Can it return a status code which will confirm the delivery of mail sent?Please suggest. Thanks, Anil (1 Reply)
Discussion started by: anil029
1 Replies

7. Red Hat

How to kill a TCP connection which has status TIME_WAIT & no PID

Hi, I want to kill TCP connections which have status as TIME_WAIT & no PID (as per the output of the "netstat - p" command). Is there any command/utility available to kill connections to a specific port or IP address. The problem is that these connections don't have process ID (see... (4 Replies)
Discussion started by: Davinder31may
4 Replies

8. Shell Programming and Scripting

PID status

Given a PID ( suppose 1356) . How do i tell if its running or not It would be really helpful if you could explain me .. I got this answer from google but i am unable to understand it ********************************************** Use kill() with 0 for the signal number. There are... (4 Replies)
Discussion started by: ultimatix
4 Replies

9. Shell Programming and Scripting

Check process running Status with PID

Good day I am fairly new to Shell Scripting. I want a script to check if a process is up by checking the process's PID and then return a value for when it's running which would be 0. If it isn't running it should give any other value that 0. Any Help is appreciated Regards (9 Replies)
Discussion started by: 1nsyz1on
9 Replies

10. Shell Programming and Scripting

Script to check status of a PID

i'm just learning scripting, and have been banging my head against this I want to check if my WAS6 java process is running and if so..echo me a messages. If not then echo me a different messages the problem i have is I dont know how to represent a NULL return value. If i grep for a was6... (14 Replies)
Discussion started by: zeekblack
14 Replies
Login or Register to Ask a Question