Sponsored Content
Top Forums Shell Programming and Scripting Help with finding the exit status of a 'nohup' command using 'PID'. Post 302917691 by SriRamKrish on Thursday 18th of September 2014 08:38:23 AM
Old 09-18-2014
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 them.
3.The master script should succeed, if and only if, all the 50 scripts that has been called succeeds. Or else should fail.(Exit 0)

So far, this is what i have tried :

Code:
 
failcount=0
passcount=0
 
while read line; do
nohup sh $line &
PID=$(echo $!)
wait $PID
status=$(echo $?)

if [ $status -eq 100 ]
        then
        echo "Script FAILED." >> ${logfile}
        failcount=$((failcount+1))
elif [ $status -eq 0 ]
        then
        echo "Script SUCCEEDED." >> ${logfile}
        passcount=$((passcount+1))
fi
done < /$PATH/script.txt
 
if [ $failcount -gt 0 ]
        then
        echo "FAILURE!" >> ${logfile}
        exit 1
else
        echo "SUCCESS!" >> ${logfile}
        exit 0
fi

But this runs the scripts sequentially and NOT parallely. I need to start all the scripts parallely using nohup(or any other means if possible) and should be able to track their exit status individually.

Kindly help.

Cheers.

Last edited by vbe; 09-18-2014 at 09:44 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to find the exit status for the last executed command

I am executing a find command in my script i.e find $2 -type f -name '*.gif' -mtime +$1 -exec rm {} \; how do i check that this command is executed properly.. i would lke t trap the errror and display my error message kinly help.. this is an urgent issue. (1 Reply)
Discussion started by: vijay.amirthraj
1 Replies

2. Shell Programming and Scripting

Getting the exit status of a remote command

Hi to everyone. How can I get the exit status from a remote command executed with rexec? :eek: machine A has RedHat Linux 9 and the remote machine B has SCO UNIX. Code: rexec -l user -p password host sh /u/files/scripts/seq_cal.sh 2006 08 I want the exit status returned by... (1 Reply)
Discussion started by: zoonalex
1 Replies

3. Shell Programming and Scripting

Move Command and exit status problem

Hi All, I am using the following code to move files from one folder to another on the remote server: ssh username@server <<EOF cd source_dir find . -type f -name "*.txt" |xargs -n1000 -i{} mv {} dest_dir if then send mail indicating error otherwise echo "success" fi EOF ... (10 Replies)
Discussion started by: visingha
10 Replies

4. 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

5. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

6. UNIX for Dummies Questions & Answers

Process status for NOHUP command

Hi, I have run a shell script as a background process using 'nohup' command. I want to see the process id of this, so that I will be able to kill it later on when required. I tried to collect these details using 'ps' command and could not view this information. How do we get this... (5 Replies)
Discussion started by: Dev_Dev
5 Replies

7. UNIX for Dummies Questions & Answers

Exit Status Of Find Command

Hello All, I am trying to capture the exit status of find command and want to delete the files only when it is successful. But it is always returning me as success even if the pattern of that file doesn't exist in the current directory. please help, checked manual page but couldn't able to figure... (6 Replies)
Discussion started by: Ariean
6 Replies

8. 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

9. Shell Programming and Scripting

Exit Status of Command

Hi All, I am doing an export and import (datapump) of 4 schema. I know we can do an export of 4 schema in one command. But just want to know how to check the exit status if i do the export/import of 4 schema in different commands in background. Please suggest. Thanks, Mani (1 Reply)
Discussion started by: pvmanikandan
1 Replies

10. UNIX for Dummies Questions & Answers

Nohup Command gets status Stopped

Good Morning I need your help please, i tried to execute this script using nohup command but it gets in status stopped nohup ./SapInterfases.sh > SapInterfases.log & prodstg02$ jobs + Stopped(SIGTTOU) nohup ./SapInterfases.sh > SapInterfases.log & I check out log: $ more... (15 Replies)
Discussion started by: alexcol
15 Replies
th_manage(1M)						  System Administration Commands					     th_manage(1M)

NAME
th_manage - manage the fault injection test harness SYNOPSIS
th_manage name instance command th_manage path command DESCRIPTION
th_manage applies the action specified by command to the instance specified by instance of the driver specified by name (or the driver instance specified by path). The driver instance must be running fault injection specifications (errdefs) defined by th_define(1M). th_manage supports several commands that operate on the driver instance specified by name and instance (or path). The commands are: broadcast Awaken all th_define processes, causing them to display their current status and exit if the errdef is now defunct (that is, if count, failcount , and acc_chk are all zero). clear_acc_chk Awaken all th_define processes. If count and failcount are already zero, then set acc_chk to zero, so that th_define exits once it has displayed its status. clear_errdefs Awaken all th_define processes. count, failcount and acc_chk are all set to zero so that all th_define commands exit once they have displayed their status. clear_errors Awaken all th_define processes. If count is already zero, set failcount and acc_chk to zero, so that th_define exits once it has displayed its status. get_handles List all the access handles. start Begin or resume execution of all errdefs. stop Suspend all errdefs for this name and instance (or path). EXAMPLES
Example 1 Useful Commands To begin the tests, enter: # th_manage foo 0 start To check the status of the errdefs, enter: # th_manage foo 0 broadcast This causes each th_define process to print out its current status. If the driver has reported a fatal error, you can take the driver offline using libdevice, clear the error condition by entering: # th_manage foo 0 clear_acc_chk or # th_manage foo 0 clear_errors and bring the driver online again using libdevice. To terminate testing, enter: # th_manage foo 0 clear_errdefs SEE ALSO
th_define(1M) SunOS 5.11 4 Jan 2001 th_manage(1M)
All times are GMT -4. The time now is 06:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy