Multiple child running parallel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple child running parallel
# 1  
Old 11-08-2012
Multiple child running parallel

Hi , I am using sun Solaris machine. The machine description is given below

SunOS ptxsa021 5.9 Generic_118558-24 sun4u sparc SUNW,Sun-Fire-15000

I am using korn shell.the scripts is below

Parent code is given below..it is the part of code

Code:
#!/bin/ksh

# Script Name: AKS_PRD_CIP_Cache_Update
 

FILE_DATE=$(date +"%Y%m%d")
CIP_PARAM_NAME=CIP
MIN_WEIGHT=0
PREV_CUTOFF_DATE=0
EXTRA_PARAM_NAME=CIP1
NO_OF_CIPS=0
CIP_TIMESTAMP=0
CREATE_ACCTS=1
 while [[ 1 -eq 1 ]]
    do
       
        NO_OF_CIPS=15
       
        
        CIP_INSTANCE=1
        
        while [[ ${CIP_INSTANCE} -le ${NO_OF_BIPS} ]]
        do
            #Check if BIP is running
            INST_ID=`printf "%02d\n" $CIP_INSTANCE`
            CIP_RUNNING=0
            CIP_RUNNING=`ps -ef|grep "bip${BILLING_PERIOD}_${INST_ID}"|egrep -v 'grep|vi|more|tail|less'| awk 'END { print NR }'`
            
            if [[ ${CIP_RUNNING} -eq 1 ]]; then
                sleep 2
                #Check if Launch Cache is running
                LAUNCH_CACHE=0
                LAUNCH_CACHE=`/usr/ucb/ps -auxwww|grep "Launch_Cache $BILLING_PERIOD $CIP_INSTANCE"|egrep -v 'grep|vi|more|tail|less'| awk 'END { print NR }'`
                
                if [[ ${LAUNCH_CACHE} -eq 0 ]]; then
                    CREATE_FILES_RES $CIP_INSTANCE
                    if [[ $CREATE_ACCTS -eq 1 ]]; then
                        CREATE_ACCOUNTS_RES $CIP_INSTANCE
                    fi
                    AKS_PRD_CIP_Launch_Cache $BILLING_PERIOD $CIP_INSTANCE $CUTOFF_DATE $CIP_PARAM_NAME $EXTRA_PARAM_NAME $MIN_WEIGHT $PREV_CUTOFF_DATE >> $LOG_FILE &
                fi
            fi
            CIP_INSTANCE=`expr ${CIP_INSTANCE} + 1`
        done
    done

child scripts part code is there

Code:
#!/bin/ksh

# Script Name: AKS_PRD_CIP_Launch_Cache
 

FILE_DATE=$(date +"%Y%m%d")
CIP_FILE_DATE=$(date +"%y%m%d")
INST_ID=`printf "%02d\n" $INSTANCE_ID`
ACCT_FILE_NAME=$ACSCIPUPDWORKDIR/ACS_CIP_ACCT_$INSTANCE_ID
CIP_FILE_NAME=`ls -rt1 $ARBORLOG/bip${BILL_PERIOD}_$INST_ID* |tail -1`
CACHE_SQL_FILE=$ACSCIPUPDWORKDIR/ACS_CIP_LOAD_CACHE_$INST_ID.sql
TEMP_ACCT=999999999
TEMP_CUTOFF_DATE=20700101
TMP_PREV_CUT=20600101
NEW_ACCNO=0
ACCT_PARAM="CIP_PROCESSING       -----Account"
ACCT_LOADED=0
NO_OF_ACCTS=0
NO_OF_MIN_WGT_ACCTS=0
TO_LOAD=1
 while [[ 1 -eq 1 ]]
    do
        ACC_NO=`sed -n "s/$CIP_PARAM_NAME/&/p" $CIP_FILE_NAME|tail -1|cut -c73-93| awk '{print $2}'`
        while [[ -z $ACC_NO ]]; do
            sleep 1
            ACC_NO=`sed -n "s/$CIP_PARAM_NAME/&/p" $CIP_FILE_NAME|tail -1|cut -c73-93| awk '{print $2}'`
        done
        
        if [[ $CURRENT_ACC -ne $ACC_NO ]]; then
            CURRENT_ACC=$ACC_NO
            NO_OF_ACCTS=`expr $NO_OF_ACCTS + 1`
            
            if [[ $ACCT_LOADED -eq $ACC_NO || $ACCT_LOADED -eq 0 ]]; then
            
                #check for line number in the accounts file
                LN=`sed -n "/$CURRENT_ACC/ =" $ACCT_FILE_NAME`
                NO_OF_PROD=`sed -n "${LN}p" $ACCT_FILE_NAME| awk '{print $3}'`
            
                #if it is not the last account
                #get the next account
            
                if [[ $LN -ne `sed -n '$=' $ACCT_FILE_NAME` ]]; then
                    LN=`expr $LN + 1`
                    NEW_ACCNO=`sed -n "${LN}p" $ACCT_FILE_NAME| awk '{print $1}'`
                    NEXT_WGT=`sed -n "${LN}p" $ACCT_FILE_NAME| awk '{print $2}'`
                    
                    if [[ $NEXT_WGT -gt $MIN_WEIGHT ]]; then
                        ACCT_LN=`sed -n "/$ACCT_PARAM $CURRENT_ACC/ =" $CIP_FILE_NAME`
                    
                        if [[ $ACCT_LOADED -ne $NEW_ACCNO || $ACCT_LOADED -eq 0 ]]; then
                            LOAD_ACCTS $ACCT_LN $NO_OF_PROD
                        fi
                    else
                        NO_OF_MIN_WGT_ACCTS=0
                        
                        while [[ $NEXT_WGT -le $MIN_WEIGHT ]]; do
                            if [[ $LN -ne `sed -n '$=' $ACCT_FILE_NAME` ]]; then
                                LN=`expr $LN + 1`
                                NEW_ACCNO=`sed -n "${LN}p" $ACCT_FILE_NAME| awk '{print $1}'`
                                NEXT_WGT=`sed -n "${LN}p" $ACCT_FILE_NAME| awk '{print $2}'`
                                NO_OF_MIN_WGT_ACCTS=`expr $NO_OF_MIN_WGT_ACCTS + 1`
                            else
                                TO_LOAD=0
                                break
                            fi
                        done
                        
                        if [[ $TO_LOAD -eq 1 ]]; then
                            ACCT_LN=`sed -n "/$ACCT_PARAM $CURRENT_ACC/ =" $CIP_FILE_NAME`
                            if [[ $ACCT_LOADED -ne $NEW_ACCNO ]]; then
                                LOAD_ACCTS $ACCT_LN $NO_OF_PROD
                            fi
                        fi
                    fi
                fi
            fi
        fi
        
        CIP_RUNNING=`ps -ef|grep "bip${BILL_PERIOD}_${INST_ID}"|egrep -v 'grep|vi|more|tail|less'| awk 'END { print NR }'`
        
        if [[ ${CIP_RUNNING} -eq 0 ]]; then
            break
        fi
    done

So when the parent script is running it is calling 15 instance of child process which is running parallel. So scripts have created many zombie processes that why CPU utilization is very high. See the below top command

Before running scripts

last pid: 26477; load averages: 40.74, 41.65, 50.03
249 processes: 207 sleeping, 8 running, 2 zombie, 3 stopped, 29 on cpu
CPU states: 0.1% idle, 80.9% user, 19.0% kernel, 0.0% iowait, 0.0% swap
Memory: 52G real, 26G free, 16G swap in use, 32G swap free


After running the parent scripts

last pid: 3941; load averages: 83.84, 82.16, 79.35
386 processes: 255 sleeping, 61 running, 45 zombie, 3 stopped, 22 on cpu
CPU states: 0.0% idle, 60.9% user, 39.1% kernel, 0.0% iowait, 0.0% swap
Memory: 52G real, 31G free, 10G swap in use, 37G swap free


See the load average is high and zombie process has increase.

So please let me know where the fault in scripts is. How I can decrease the zombie process. It is taken all the cpu utilization.
please see the zombie process
Code:
ind_lml@tty106> ps -eo pcpu,pid,user,args | sort -r -k1 | less | grep -i ind_lml
 0.3 22331  ind_lml ps -ef
 0.2 27274  ind_lml top
 0.1 29530  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1 29347  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1 29211  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1 29021  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Cache_U
 0.1 26830  ind_lml -tcsh
 0.1 22366  ind_lml less
 0.1 22364  ind_lml ps -eo pcpu,pid,user,args
 0.1 22345  ind_lml sed -n s/CIP_PROCESSING/&/p /home/tst_tml/log/bip16_09-121108-101622-03-24999.B
 0.1 22344  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1 22338  ind_lml ps -ef
 0.1 22297  ind_lml cut -c73-93
 0.1 22284  ind_lml awk END { print NR }
 0.1  5340  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1  3621  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1  2958  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1  2319  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1  1563  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.1  1005  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 29985  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 29709  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22360  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22349  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22348  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22346  ind_lml tail -1
 0.0 22340  ind_lml egrep -v grep|vi|more|tail|less
 0.0 22339  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22337  ind_lml awk END { print NR }
 0.0 22336  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22334  ind_lml grep bip16_01
 0.0 22332  ind_lml egrep -v grep|vi|more|tail|less
 0.0 22330  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22325  ind_lml awk END { print NR }
 0.0 22319  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22307  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22306  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22301  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22290  ind_lml awk {print $2}
 0.0 22273  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22266  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0 22235  ind_lml awk END { print NR }
 0.0 22203  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0  8638  ind_lml /opt/SUNWspro/WS6U2/bin/sparcv9/dbx -g stdio -c cd /home/ind_lml/pvcs/custom/sr
 0.0  8423  ind_lml /usr/dt/bin/ttsession -p -c workshop -D ACSPreCOMCAPFilter
 0.0  6609  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0  4507  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0   547  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
 0.0   272  ind_lml /bin/ksh /arbor/arbor_arbfxcat/site_specific/custom/scripts/AKS_PRD_CIP_Launch_
   - 22362  ind_lml <defunct>
   - 22361  ind_lml <defunct>
   - 22353  ind_lml <defunct>
   - 22350  ind_lml <defunct>
   - 22343  ind_lml <defunct>
   - 22342  ind_lml <defunct>
   - 22333  ind_lml <defunct>
   - 22329  ind_lml <defunct>
   - 22328  ind_lml <defunct>
   - 22327  ind_lml <defunct>
   - 22321  ind_lml <defunct>
   - 22320  ind_lml <defunct>
   - 22315  ind_lml <defunct>
   - 22314  ind_lml <defunct>
   - 22312  ind_lml <defunct>
   - 22292  ind_lml <defunct>
   - 22291  ind_lml <defunct>
   - 22289  ind_lml <defunct>
   - 22287  ind_lml <defunct>
   - 22286  ind_lml <defunct>
   - 22285  ind_lml <defunct>
   - 17511  ind_lml <defunct>
ind_lml@tty106>

# 2  
Old 11-08-2012
Unassigned variable & Exit Condition

In the parent script I see below highlighted variable is not initialized, I think the variable name should be NO_OF_CIPS instead:-
Code:
while [[ ${CIP_INSTANCE} -le ${NO_OF_BIPS} ]]

Also I noticed parent script is running inside an infinite loop, what is the exit condition?
# 3  
Old 11-08-2012
yes it is NO_OF_CIPS variable.

Parent is the deamon process .for stoping this process need to kill


---------- Post updated at 08:18 AM ---------- Previous update was at 08:13 AM ----------

here my question is how to decrease the zombie process
# 4  
Old 11-09-2012
Put a wait system call inside the outer while loop of your parent script and re-try:-
Code:
        CIP_INSTANCE=`expr ${CIP_INSTANCE} + 1`
        done
        wait # here
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running script in Parallel

Hi Folks I have a doubt. I have a script which is running with 2 input parameters ./GetDSLnkCount.sh <jobnumber> Parmfile.txt I need to run the script in parallel for different jobnumbers. The commands are ./GetDSLnkCount.sh jnhuc14500 Parmfile.txt ./GetDSLnkCount.sh jnhuc14501... (3 Replies)
Discussion started by: morbid_angel
3 Replies

2. Shell Programming and Scripting

[Solved] Running scripts in parallel

i have script A and script B, both scripts have to run in parallel, my requirement is script A create table temp1, post creating it will run fr 4 hrs , script B has to start 0nly after creation of table temp1 ( which is done by script A) , again script B will run for 5 hrs if i run sequencially... (7 Replies)
Discussion started by: only4satish
7 Replies

3. UNIX for Dummies Questions & Answers

Running parallel process

i am having 4 process,have to run parallel and not after one by one. sample1.sh sample2.sh sample3.sh sample4.sh Thanks in advance. i (11 Replies)
Discussion started by: sagar_1986
11 Replies

4. Shell Programming and Scripting

Running uniq -c and sort -nr in parallel.

Hi All, I have a huge collection of files in a directory about 200000. I have the command below but it only uses one core of the computer. I want it to do task in parallel. This is the command that I want to run in parallel: sort testfile | uniq -c | sort -nr I know how to run sort... (10 Replies)
Discussion started by: shoaibjameel123
10 Replies

5. Shell Programming and Scripting

Running jobs in parallel

I need to process 50 sqlplus scripts which are listed in a text file. I need to develop a shell script that'll read this file and run these sqlplus scripts. At any point of time, the number of sqlplus scripts running shouldn't exceed 6. If any of the sqlplus scripts completes successfully then... (17 Replies)
Discussion started by: gctex
17 Replies

6. Shell Programming and Scripting

36 Child Processes not running as desired

I have a parent process which will start 36 child process. This I achieved by using the 'for loop'. In Parent.sh:- ./Child.sh <arg1> <arg2> ... & If I execute "ps -ef | grep Child.sh", I can see 72 child processes running at the background. I mean I can see the duplicate of each process. ... (2 Replies)
Discussion started by: nthiruvenkatam
2 Replies

7. Shell Programming and Scripting

multiple child scripts running in backgroud, how to use grep on the parent?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (5 Replies)
Discussion started by: albertashish
5 Replies

8. IP Networking

running servers parallel

I'm going to undertake a hardware refresh soon and I was wondering if it is possible to run two machines (X and Y) with the same hostname (but different IP addresses) on the same network? Server X is the original server and has an entry in DNS. Server Y is the new server and won't have an entry... (1 Reply)
Discussion started by: soliberus
1 Replies

9. Shell Programming and Scripting

Running scripts in parallel

Hi, Iam having the scripts as follows. i jus want to run those in parallel. main aim is to minimise the time for overall execution of the script. now out.txt is having 1 lac records. script1(split.sh) split -1000 out.txt splitout ls -A splitout* > filelist.txt cat filelist.txt... (6 Replies)
Discussion started by: nivas
6 Replies

10. Programming

running a parallel program

hi , i need to run a parallel program . for example; program1 { array=" the second program should called here : program 2" the execution should continue } the 2nd program should recieve an array of information as argument and it should... (4 Replies)
Discussion started by: bankpro
4 Replies
Login or Register to Ask a Question