Log file for a Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Log file for a Script
# 1  
Old 04-12-2007
Log file for a Script

Oracle92 on solaris 8.

We have a Truncate Script that runs every night to cleanup certain tables , so new data gets loaded into. This Script is run in Unix Shell script where i set Environment varibles, and things like that..

Now, how do i create a log file of the script , to see weather the script really deleted the data ?

==========================
#!/bin/ksh
ORACLE_BASE=/u10/app/ORACLE
ORACLE_DOC=$ORACLE_BASE/doc
ORACLE_HOME=$ORACLE_BASE/product/9.2.0.1.0
ORACLE_SID=dss
PATH=/usr/bin:/usr/ucb:/usr/sbin:/etc:/usr/inform/PowerMart:/usr/inform/RepServer:/usr/inform/scripts:$ORACLE_HOME/bin:/usr/bin:/bin:/usr/ccs/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/local/bin:.
TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=/usr/inform/PowerMart:/usr/inform/RepServer:$ORACLE_HOME/lib32
export PATH PM_HOME ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH TNS_ADMIN
export PARMS=/usr/inform/scripts/WorkFlow/dss_parms
ORADBUSER=`cat $PARMS |grep ORADBUSER|cut -d":" -f2`
ORADBPASSWD=`cat $PARMS |grep ORADBPASSWD|cut -d":" -f2`

$ORACLE_HOME/bin/sqlplus -s << EOF
$ORADBUSER/$ORADBPASSWD
set heading off;
set feedback off;
set echo off;
truncate table current_year;
commit;
=============================

Thanks
Ron
# 2  
Old 04-12-2007
The simplest way, assuming you are using cron to run the script is to redirect the cron job stdout and stderr to a file.
# 3  
Old 04-12-2007
Dear

if you are runnning the script from crontab,then the output will be mailed to the owner user.

also you can put the script output in one file and the error in another one as below

your_script.sh > outfile 2> errfile

Regards;
TheEngineer
IBM Certified Specialist
# 4  
Old 04-12-2007
i see in your script that you do "set echo off", however it is related to oracle ,to see the truncate command output set echo on so you will findout weather it truncate the table or not
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

2. UNIX for Beginners Questions & Answers

Monitoring script for Log file

Hi, Iam new to unix , plz help me to write below script. I need to write a script for Monitoring log file when any error occurs it has to send a mail to specified users and it should be always pick latest error not the existing one and the script should be able to send mail all errors (more... (1 Reply)
Discussion started by: vij05
1 Replies

3. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

4. Shell Programming and Scripting

Shell Script to grep Job File name and Log File name from crontab -l

Hello, I am new to shell scripting. I need to write a shell script where i can grep the name of file ie. .sh file and log file from crontab -l. #51 18 * * * /home/oracle/refresh/refresh_ug634.sh > /home/oracle/refresh/refresh_ug634.sh.log 2>&1 #40 17 * * * /home/oracle/refresh/refresh_ux634.sh... (1 Reply)
Discussion started by: guptra
1 Replies

5. UNIX for Advanced & Expert Users

Script to read log file

Hi, Im looking for a shell script which will search for a particular string in a log file as below scenario 1. I need to run URL http://localhost/client/update?feedid=200 in shell script at(eg)4:00 PM which will not take more than 15 mins to complete. 2. After 15 mins i need to... (6 Replies)
Discussion started by: Paulwintech
6 Replies

6. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

7. Shell Programming and Scripting

Script extract from log file

Hi i new to scripting and am trying to create a script to pull my current of logs from /var/logs/secure and name it securelog-Month-Day-Hour.txt example: grep 'Mar 5 11' /var/logs/secure > /home/(user)/Documents/Logs/mylog-02-1-11 How do i set the targeted strings to be the current... (2 Replies)
Discussion started by: M47H415
2 Replies

8. Shell Programming and Scripting

log file script

I have a log which is configured as follows: date time code1 notes: code2 A monthly job is run based on information supplied from this log. The end of each monthly job is clearly indicated by a code within 'code1'. At this time someone is performing a less on the log, moving to the end,... (2 Replies)
Discussion started by: bwatlington
2 Replies

9. UNIX for Dummies Questions & Answers

Script for parsing details in a log file to a seperate file

Hi Experts, Im a new bee for scripting, I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies

10. Shell Programming and Scripting

Help with script parsing a log file

I have a large log file, which I want to first use grep to get the specific lines then send it to awk to print out the specific column and if the result is zero, don't do anything. What I have so far is: LOGDIR=/usr/local/oracle/Transcription/log ERRDIR=/home/edixftp/errors #I want to be... (3 Replies)
Discussion started by: mevasquez
3 Replies
Login or Register to Ask a Question