Help with executing parallel sessions for same shell script with different but fixed parameters

Hi Experts,

There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed.
Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select query but only one value changes in the where condition for a column as specified below.

e.g.

1)
sqlplus -s $ORA_CONN << EOF!
           SPOOL ${rep_name}report_${rep_part}_${sysdate1}.txt;
        SELECT * FROM customer WHERE col1=2001
           AND (  col2='sumthing')
        UNION
        SELECT * FROM customer WHERE col1=2001
        AND (condition);
        Spool off;
exit
EOF!
;;
2)
sqlplus -s $ORA_CONN << EOF!
           SPOOL ${rep_name}report_${rep_part}_${sysdate1}.txt;
        SELECT * FROM customer WHERE col1=2002
           AND (  col2='sumthing')
        UNION
        SELECT * FROM customer WHERE col1=2002
        AND (condition);
        Spool off;
exit
EOF!
;;

execution::

./script_name.ksh 1
./script_name.ksh 2
...
./script_name.ksh 25
 

But I want to execute this script parallely for all 25 options without opening separate shells.

Kindly help.

Many Thanks!

run all scripts in background. create one script like below.

#!/bin/ksh
./script_name.ksh 1 &
./script_name.ksh 2 &
...
./script_name.ksh 25 &

then execute this script

./allScripts.ksh

1 Like

I have created a script as instructed above and ran it.
Can you please expain how this works.
Does it create different threads and execute it in different sessions.
For me its giving a big error in sql as its not able to decrypt the password.
There is a line to decrypt password and I have copied it in both main script and sunscript but still its not working. Its displaying as below.
username/@database
I don't know why but its not able to retain the password.
Since its not able to logon so its not executing the query.
May be I am not interpreting it correctly.
So I am pasting the big error below.

SQL*Plus: Release 10.2.0.2.0 - Production
reprompting on error.
 
Runs the specified SQL*Plus script from a web server (URL) or the
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
-M "<options>" Sets automatic HTML markup of output. The options
local file system (filename.ext) with specified parameters that
have the form:
will be assigned to substitution variables in the script.
Usage 1: sqlplus -H | -V
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
+ [ 0 -ne 0 ]
+ echo export report_run_date=07/12/2010
-H Displays the SQL*Plus version and the
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
usage help.
When SQL*Plus starts, and after CONNECT commands, the site profile
-R <level> Sets restricted mode to disable SQL*Plus commands
-V Displays the SQL*Plus version.
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
Usage 2: sqlplus [ [<option>] [<logon>] [<start>] ]
disables all user commands interacting with the
(e.g. login.sql in the working directory) are run. The files may
<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
file system.
contain SQL*Plus commands.
-S Sets silent mode which suppresses the display of
 
-C <version> Sets the compatibility of affected commands to the
Refer to the SQL*Plus User's Guide and Reference for more information.
version specified by <version>. The version has
the SQL*Plus banner, prompts, and echoing of
the form "x.y[.z]". For example, -C 10.2.0
commands.
-L Attempts to log on just once, instead of
<logon> is: (<username>[/<password>][@<connect_identifier>] | /)
reprompting on error.
[AS SYSDBA | AS SYSOPER] | /NOLOG
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
Specifies the database account username, password and connect
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
identifier for the database connection. Without a connect
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
identifier, SQL*Plus connects to the default database.
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
The AS SYSDBA and AS SYSOPER options are database administration
be 1, 2 or 3. The most restrictive is -R 3 which
privileges.
disables all user commands interacting with the
+ [ 0 -ne 0 ]
file system.
The /NOLOG option starts SQL*Plus without connecting to a
database.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
<start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]
commands.
 
Runs the specified SQL*Plus script from a web server (URL) or the
<logon> is: (<username>[/<password>][@<connect_identifier>] | /)
local file system (filename.ext) with specified parameters that
will be assigned to substitution variables in the script.
[AS SYSDBA | AS SYSOPER] | /NOLOG
 
When SQL*Plus starts, and after CONNECT commands, the site profile
Specifies the database account username, password and connect
 
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
+ 0<<
identifier for the database connection. Without a connect
(e.g. login.sql in the working directory) are run. The files may
identifier, SQL*Plus connects to the default database.
contain SQL*Plus commands.
 
Refer to the SQL*Plus User's Guide and Reference for more information.
The AS SYSDBA and AS SYSOPER options are database administration
privileges.
 

Also where I can view the progress of threads.

this is nothing but running all scripts in background. post how $ORA_CONN variable is being set?

Many Thanks for your help.
Its working fine now as I have given statement sleep 30 in b/w the script call.
Earlier it was not getting enough time to run decrypt password script.

If I want to run the script with the parameter of a column value then how can I get it. I want to call script_name.ksh as many time as id in customer table and also pass it as a parameter to script.
someting Like below.

 
for i in select id from customer
do
./script_name.ksh $i &
done

---------- Post updated at 12:57 AM ---------- Previous update was at 12:13 AM ----------

I have figured out how to have ID from customer but now how to call shell script within for loop. Kindly help.

 
sqlplus -s $ORA_CONN <<EOF
SET SERVEROUTPUT ON
SET FEED OFF
spool abc.txt
BEGIN
   FOR i IN (SELECT ID FROM customer)
   LOOP
      DBMS_OUTPUT.put_line ( 'value ' || i.ID);
           END LOOP;
END;
/
spool off
EOF

If I m not wrong, you are trying to execute same query for 25 column ids on a customer table at a single time.

For that your following qeury will list out column ids in abc.txt file. Correct?

sqlplus -s $ORA_CONN <<EOF
SET SERVEROUTPUT ON
SET FEED OFF
spool abc.txt
BEGIN
   FOR i IN (SELECT ID FROM customer)
   LOOP
      DBMS_OUTPUT.put_line ( 'value ' || i.ID);
   END LOOP;
END;
/
spool off
EOF

abc.txt will look like

Now to execute same query as follows on all listed column ids, you can write a script like

#!/bin/ksh

    # First list out Column ids in abc.txt file
sqlplus -s $ORA_CONN <<EOF
SET SERVEROUTPUT ON
SET FEED OFF
spool abc.txt
BEGIN
   FOR i IN (SELECT ID FROM customer)
   LOOP
      DBMS_OUTPUT.put_line ( 'value ' || i.ID);
   END LOOP;
END;
/
spool off
EOF

    # Now for each data in abc.txt, execute second query in background
for myID in `cat abc.txt | xargs`
do
sqlplus -s $ORA_CONN <<EOF!
        SPOOL ${rep_name}report_${rep_part}_${sysdate1}.txt;
        SELECT * FROM customer WHERE col1="$myID"
           AND (  col2='sumthing')
        UNION
        SELECT * FROM customer WHERE col1="$myID"
        AND (condition);
        Spool off;
exit
EOF! &
done
1 Like

Many Thanks for the advice.
Can this be implemented by dbms_scheduler package.

Again I am facing a problem in this script.
After we have ran above for loop it will generate mulitple o/p files depenind upon condition. Now what I need to do is to combine this o/p in a single file. Then remove blank lines from file and return the record count of the file into the log. I have written the script & this part is working fine if I already have all o/p files created. Then its firstly checking whether the number of records for select statement is matching with files created successfully in the log file. If its so then it will append all o/p files, remove blank lines & return rec count. Otherwise it will sleep for 60 secs and then rerun that function. Now the o/p file (total of 24 o/p files are there) creation takes 7 hrs 30 mins types. When I ran it fully it keep on running the function till 20 files are generated after that its not checking the rec count and doesn't create a full report file.

 
 
sys_date=`date '+%d_%m_%Y:%H:%M:%S'`
sysdate1=`date '+%d_%m_%Y`
sqlplus -s $ORA_CONN << EOF
SET SERVEROUTPUT ON
SET FEED OFF
spool org.txt
BEGIN
   FOR i IN (SELECT ID FROM table ID<>0)
   LOOP
      DBMS_OUTPUT.put_line ( i.ID);
   END LOOP;
END;
/
spool off
EOF
for i in `cat org.txt`
do
./subscript.ksh $i &
sleep 10
done
cnt1=`sqlplus -s $ORA_CONN <<EOF
SET SERVEROUTPUT ON
SET FEED OFF
SET HEADING OFF
SELECT count(*) FROM table where ID<>0;
exit
EOF`
org_cnt=`echo ${cnt1}`
check_count()
{
count=`grep -c 'Finished successfully' $LOG_FILE`
if [[ ${count} == ${org_cnt} ]] then
grep 'Finished successfully' $LOG_FILE | cut -d" " -f12 > ${file}
        for i in `cat ${file}`
        do
        cat $i >> ${report}
        done
else
        sleep 60
        check_count
fi
}
check_count
grep -v "^$" ${report_name} > ${report_name}.new
mv ${report_name}.new ${report_name}
 
rec_cnt=`wc -l ${report_name} | tr -s " " | cut -d" " -f2`
echo Report has been generated successfully ${report_name} with record count ${rec_cnt} >>$LOG_FILE
 

I guess $LOGNAME is your common log file where u maintain the status of all finished ./subscript.ksh script. Now u r going to check in loop whether that log file has an entry of all inputted ids, right? And once all scripts running in background finishes, u are going to display Report has been successfully generated. Correct? Please revert with $LOGFILE and correct if I have missed out any point.

Yes you are right. After all the scripts running in background finishes, I need to generate single report by appending these files and then removing blank line from it. Then also need to log record count of final report into the logfile. The logfile is commom n its name is $LOG_FILE.Below is log file I have placed checkpoints in function to check whether its in if loop or else loop and also displayed count of files that have finished their processing running in background after every 1 minute.But if you check here it has stopped displaying the count after [2010-12-17 06:39:56]. Kindly help.

 
[2010-12-17 04:26:47] PID=27136 START ./subscript.ksh for unit:1001 
[2010-12-17 04:27:00] PID=27781 START ./subscript.ksh for unit:1002 
[2010-12-17 04:27:08] PID=28459 START ./subscript.ksh for unit:1003 
[2010-12-17 04:27:18] PID=28934 START ./subscript.ksh for unit:1004 
[2010-12-17 04:27:28] PID=29567 START ./subscript.ksh for unit:1005 
[2010-12-17 04:27:38] PID=214 START ./subscript.ksh for unit:1006 
[2010-12-17 04:27:48] PID=760 START ./subscript.ksh for unit:2001 
[2010-12-17 04:27:58] PID=1352 START ./subscript.ksh for unit:2002 
[2010-12-17 04:28:09] PID=2004 START ./subscript.ksh for unit:2003 
[2010-12-17 04:28:19] PID=2600 START ./subscript.ksh for unit:2004 
[2010-12-17 04:28:29] PID=3156 START ./subscript.ksh for unit:3001 
[2010-12-17 04:28:39] PID=3836 START ./subscript.ksh for unit:3002 
[2010-12-17 04:28:40] PID=3836 OK ./subscript.ksh - Finished successfully for full report report_3002_17_12_2010:04:28:39.txt
[2010-12-17 04:28:49] PID=4431 START ./subscript.ksh for unit:3003 
[2010-12-17 04:28:59] PID=4999 START ./subscript.ksh for unit:3004 
[2010-12-17 04:29:09] PID=5672 START ./subscript.ksh for unit:4001 
[2010-12-17 04:29:19] PID=6265 START ./subscript.ksh for unit:4002 
[2010-12-17 04:29:28] PID=6815 START ./subscript.ksh for unit:4003 
[2010-12-17 04:29:39] PID=7436 START ./subscript.ksh for unit:5001 
[2010-12-17 04:29:49] PID=8135 START ./subscript.ksh for unit:5002 
[2010-12-17 04:29:59] PID=8703 START ./subscript.ksh for unit:5003 
[2010-12-17 04:30:09] PID=9289 START ./subscript.ksh for unit:5004 
[2010-12-17 04:30:19] PID=9973 START ./subscript.ksh for unit:5005 
[2010-12-17 04:30:29] PID=10521 START ./subscript.ksh for unit:6001 
[2010-12-17 04:30:30] PID=10521 OK ./subscript.ksh - Finished successfully for full report report_6001_17_12_2010:04:30:29.txt
[2010-12-17 04:30:39] PID=10963 START ./subscript.ksh for unit:6002 
[2010-12-17 04:30:40] PID=10963 OK ./subscript.ksh - Finished successfully for full report report_6002_17_12_2010:04:30:39.txt
[2010-12-17 04:30:45] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:31:45] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:31:45] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:32:45] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:32:45] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:33:45] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:33:45] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:34:45] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:34:45] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:35:45] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:35:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:36:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:36:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:37:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:37:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:38:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:38:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:39:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:39:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:40:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:40:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:41:46] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:41:46] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:42:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:42:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:43:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:43:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:44:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:44:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:45:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:45:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:46:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:46:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:47:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:47:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:48:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:48:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:49:47] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:49:47] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:50:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:50:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:51:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:51:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:52:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:52:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:53:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:53:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:54:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:54:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:55:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:55:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:56:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:56:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:57:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:57:48] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:58:48] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:58:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 04:59:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 04:59:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:00:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 05:00:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:01:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 05:01:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:02:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 05:02:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:03:22] PID=28934 OK ./subscript.ksh - Finished successfully for full report report_1004_17_12_2010:04:27:18.txt
[2010-12-17 05:03:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 3
[2010-12-17 05:03:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:04:15] PID=2600 OK ./subscript.ksh - Finished successfully for full report report_2004_17_12_2010:04:28:19.txt
[2010-12-17 05:04:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 4
[2010-12-17 05:04:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:05:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 5
[2010-12-17 05:05:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:06:27] PID=214 OK ./subscript.ksh - Finished successfully for full report report_1006_17_12_2010:04:27:38.txt
[2010-12-17 05:06:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 5
[2010-12-17 05:06:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:07:49] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:07:49] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:08:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:08:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:09:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:09:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:10:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:10:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:11:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:11:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:12:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:12:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:13:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:13:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:14:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:14:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:15:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:15:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:16:50] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:16:50] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:17:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:17:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:18:43] PID=9289 OK ./subscript.ksh - Finished successfully for full report report_5004_17_12_2010:04:30:09.txt
[2010-12-17 05:18:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 6
[2010-12-17 05:18:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:19:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 7
[2010-12-17 05:19:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:20:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 7
[2010-12-17 05:20:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:21:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 7
[2010-12-17 05:21:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:22:24] PID=8135 OK ./subscript.ksh - Finished successfully for full report report_5002_17_12_2010:04:29:49.txt
[2010-12-17 05:22:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 7
[2010-12-17 05:22:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:23:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 8
[2010-12-17 05:23:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:24:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 8
[2010-12-17 05:24:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:25:18] PID=27781 OK ./subscript.ksh - Finished successfully for full report report_1002_17_12_2010:04:27:00.txt
[2010-12-17 05:25:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 8
[2010-12-17 05:25:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:26:51] PID=26706 INFO ./allscripts.ksh - ELSE statement count 9
[2010-12-17 05:26:51] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:27:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 9
[2010-12-17 05:27:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:28:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 9
[2010-12-17 05:28:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:29:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 9
[2010-12-17 05:29:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:30:25] PID=8703 OK ./subscript.ksh - Finished successfully for full report report_5003_17_12_2010:04:29:59.txt
[2010-12-17 05:30:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 9
[2010-12-17 05:30:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:31:30] PID=9973 OK ./subscript.ksh - Finished successfully for full report report_5005_17_12_2010:04:30:19.txt
[2010-12-17 05:31:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 10
[2010-12-17 05:31:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:32:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 11
[2010-12-17 05:32:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:33:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 11
[2010-12-17 05:33:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:34:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 11
[2010-12-17 05:34:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:35:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 11
[2010-12-17 05:35:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:36:50] PID=28459 OK ./subscript.ksh - Finished successfully for full report report_1003_17_12_2010:04:27:08.txt
[2010-12-17 05:36:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 11
[2010-12-17 05:36:52] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:37:52] PID=26706 INFO ./allscripts.ksh - ELSE statement count 12
[2010-12-17 05:37:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:38:35] PID=4999 OK ./subscript.ksh - Finished successfully for full report report_3004_17_12_2010:04:28:59.txt
[2010-12-17 05:38:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 12
[2010-12-17 05:38:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:39:51] PID=7436 OK ./subscript.ksh - Finished successfully for full report report_5001_17_12_2010:04:29:39.txt
[2010-12-17 05:39:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 13
[2010-12-17 05:39:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:40:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:40:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:41:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:41:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:42:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:42:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:43:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:43:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:44:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:44:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:45:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:45:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:46:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:46:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:47:32] PID=27136 OK ./subscript.ksh - Finished successfully for full report report_1001_17_12_2010:04:26:47.txt
[2010-12-17 05:47:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 14
[2010-12-17 05:47:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:48:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:48:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:49:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:49:53] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:50:53] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:50:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:51:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:51:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:52:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:52:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:53:05] PID=29567 OK ./subscript.ksh - Finished successfully for full report report_1005_17_12_2010:04:27:28.txt
[2010-12-17 05:53:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 15
[2010-12-17 05:53:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:54:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 16
[2010-12-17 05:54:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:55:07] PID=6265 OK ./subscript.ksh - Finished successfully for full report report_4002_17_12_2010:04:29:19.txt
[2010-12-17 05:55:08] PID=6815 OK ./subscript.ksh - Finished successfully for full report report_4003_17_12_2010:04:29:28.txt
[2010-12-17 05:55:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 16
[2010-12-17 05:55:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:56:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 05:56:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:57:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 05:57:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:58:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 05:58:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 05:59:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 05:59:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:00:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:00:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:01:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:01:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:02:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:02:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:03:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:03:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:04:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:04:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:05:54] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:05:54] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:06:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:06:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:07:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:07:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:08:09] PID=5672 OK ./subscript.ksh - Finished successfully for full report report_4001_17_12_2010:04:29:09.txt
[2010-12-17 06:08:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 18
[2010-12-17 06:08:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:09:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:09:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:10:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:10:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:11:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:11:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:12:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:12:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:13:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:13:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:14:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:14:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:15:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:15:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:16:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:16:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:17:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:17:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:18:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:18:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:19:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:19:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:20:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:20:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:21:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:21:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:22:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:22:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:23:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:23:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:24:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:24:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:25:37] PID=2004 OK ./subscript.ksh - Finished successfully for full report report_2003_17_12_2010:04:28:09.txt
[2010-12-17 06:25:55] PID=26706 INFO ./allscripts.ksh - ELSE statement count 19
[2010-12-17 06:25:55] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:26:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:26:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:27:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:27:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:28:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:28:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:29:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:29:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:30:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:30:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:31:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:31:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:32:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:32:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:33:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:33:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:34:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:34:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:35:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:35:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:36:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:36:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:37:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:37:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:38:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 06:38:56] PID=26706 INFO ./allscripts.ksh - checkcount function
[2010-12-17 06:39:56] PID=26706 INFO ./allscripts.ksh - ELSE statement count 20
[2010-12-17 07:06:20] PID=3156 OK ./subscript.ksh - Finished successfully for full report report_3001_17_12_2010:04:28:29.txt
[2010-12-17 09:21:49] PID=760 OK ./subscript.ksh - Finished successfully for full report report_2001_17_12_2010:04:27:48.txt
[2010-12-17 10:24:59] PID=1352 OK ./subscript.ksh - Finished successfully for full report report_2002_17_12_2010:04:27:58.txt

The log file quite long. Is there any option to attach a file. I am not able to locate any such.

sys_date=`date '+%d_%m_%Y:%H:%M:%S'`
sysdate1=`date '+%d_%m_%Y`
sqlplus -s $ORA_CONN << EOF
SET SERVEROUTPUT ON
SET FEED OFF
spool org.txt
BEGIN
   FOR i IN (SELECT ID FROM table ID<>0)
   LOOP
      DBMS_OUTPUT.put_line ( i.ID);
   END LOOP;
END;
/
spool off
EOF
for i in `cat org.txt`
do
./subscript.ksh $i &
sleep 10
done
# Why do u need to fire a query in database to get records count??
org_cnt=`wc -l org.txt`
# Why 2 variables needed??
count=0
while [ ${count} == ${org_cnt} ]
do
    count=`grep 'Finished successfully' $LOG_FILE | wc -l`
    sleep 60
done

echo Report has been generated successfully ${report_name} with record count ${rec_cnt}

P.S. I have not added a code for appanding all completed process' individual log into common logfile. That u need to modify. Please revert if any doubt.

1 Like

Many Thanks Rohon!
I have ran the script as suggested. It's working fine as of now.
Can you please tell me why my logic of implementing it by function didn't work.