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
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)
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)
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)
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)
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)
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)
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)
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)
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)