Ksh: How to write the log file simultaneously when .sql file executes by UNIX process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ksh: How to write the log file simultaneously when .sql file executes by UNIX process
# 1  
Old 12-29-2016
Ksh: How to write the log file simultaneously when .sql file executes by UNIX process

Hello Team-

we would like to implement an approach which has to write the log file simultaneously
when .sql file is executing by Unix process. At present,it is writing the log file
once the process is completed. I've tested the current process with the below
approaches and none of them writes to it simultaneously.

Please suggest, is there any other way to accomplish this. Do we have any limitations
on buffer size in unix server such as,the process has to write the logs after some
size(500 kb etc) or write the logs once the process is completed to overcome cost etc.
I think, these factors are based upon server settings, configurations etc. Any idea?

Psuedo code:
1.
Code:
#!/bin/ksh
#Script: main_shell.sh 
	Few lines fo code 
	----------------
	----------------
nohup job_instance.sh >/dev/null 2>&1 & 
	-------------
	-------------

2.
Code:
#!/bin/ksh
#Script: job_instance.sh 
	Few lines fo code 
	----------------
	----------------
sqlplus -s ${DB_STRING} @test.sql $arg1 $arg2 >> ${LOG_PATH}/${LOG_FILE_NAME}
(tried with below 1 thru 10 options for log creation parallely, didn't work out)
	-------------
	-------------

Note: At 2nd shell, the log file has to write parallely when .sql file runs by
2nd shell. It means, expecting line by line logs when we refresh it. At present,
the log file is writing once the process has completed.

Code:
1. sqlplus -s ${DB_STRING}  @test.sql >> ${LOG_PATH}/${LOG_FILE_NAME}
2. nohup sqlplus -s ${DB_STRING} @test.sql >> ${LOG_PATH}/${LOG_FILE_NAME} & 	
3. sqlplus -s ${DB_STRING} @test.sql >> ${LOG_PATH}/${LOG_FILE_NAME}  2>&1 & 	
4. $sqlplus -s ${DB_STRING} @test.sql  <<EOF 1>>${LOG_PATH}/${LOG_FILE_NAME} 2>&1 
5. sqlplus -s ${DB_STRING} @test.sql | tee -a ${LOG_PATH}/${LOG_FILE_NAME}
6. $(sqlplus -s ${DB_STRING} <<-EOS
7. SPOOL ${LOG_PATH}/${LOG_FILE_NAME}
			APPEND @test.sql
			SPOOL OFF
			exit;
			EOS
8. sqlplus -s ${DB_STRING} @test.sql 
9. sqlplus -s ${DB_STRING} @test.sql 3>&1 1>>${LOG_PATH}/${LOG_FILE_NAME} 2>&1 
10. nohup $ORACLE_HOME/bin/sqlplus -s $DB_STRING @test.sql > ${LOG_PATH}/${LOG_FILE_NAME} &

Thank you for your support and appreciate your help..!!

Please let me know If you have any questions.

Thanks
Hima

Last edited by Scrutinizer; 12-30-2016 at 01:02 AM.. Reason: Code tags also for pseudo code
# 2  
Old 12-30-2016
I would think the problem lies in the sqlplus log output buffer, so if it is possible, then it should be a sqlplus tunable..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Not able to write SQL query output in to .csv file with shell script.

I am trying to write SQL query output into a .csv file. But in the output columns are displaying in different lines instead of coming in one line. Main Code shell script: this is my code: #!/bin/bash file="db_detail.txt" . $file rm /batch/corpplan/bin/dan.csv... (6 Replies)
Discussion started by: sandeepgoli53
6 Replies

2. Shell Programming and Scripting

Need to write shell script for my .sql file call

Hi Guys, I need to write a simple shell script which will generate a .csv file/report by calling .sql file inside a shell script. Can somebody help me on this. Thanks in advance! Regards, LK (7 Replies)
Discussion started by: lakshmanraok117
7 Replies

3. Shell Programming and Scripting

Multiple process write to same log file at the same time

If we have 3 process to write to same log file at the same time like below. will it cause the data outdated because the multiple process writing same time? It this a safe way to keep the log for multiple process? p1 >> test.log &; p2 >> test.log &; p3 >> test.log & Thanks, (5 Replies)
Discussion started by: casttree
5 Replies

4. Shell Programming and Scripting

Writing sql results to file using ksh -nevermind

I'm having problems with writing my sql results to a file: sqlplus -S username/password@DB <<!! set echo off set verify off set showmode off set feedback off set timing off set linesize 250 set wrap off set pagesize 0 set newpage none set tab off set trimspool on set colsep... (1 Reply)
Discussion started by: avillanueva
1 Replies

5. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

6. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

7. Shell Programming and Scripting

Write process output to a file

When I run <ls -l> to get a list of all the files, I want the displayed result to be written to a text file. Is there a way to do that? (1 Reply)
Discussion started by: kn.naresh
1 Replies

8. Shell Programming and Scripting

Catch a PL/SQL exception in ksh file

Hi all Im trying to call a PL SQl block from a ksh file like this : sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof whenever SQLERROR exit 1 var varError VARCHAR2(200); exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:varError); eof If there is a error then varError will return a... (1 Reply)
Discussion started by: Sam123
1 Replies

9. Shell Programming and Scripting

Need to write a script in UNIX to find a file if another file exists

So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following. Search all the applications subdirectories for message.jar. If the message.jar file exists, I need to search the application directory for... (1 Reply)
Discussion started by: mmdawg
1 Replies

10. Shell Programming and Scripting

How to write a varible into file in ksh

set filename $logDir/PyLog/$logname echo $filename >> logname.txt I am trying to write to write the varibale filename into a file logname.txt,it is not working could any one suggest y (2 Replies)
Discussion started by: nathgopi214
2 Replies
Login or Register to Ask a Question