Log file Creation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log file Creation
# 1  
Old 02-06-2013
Log file Creation

Hi

I have unix script which does execute some OS commands and DB Commands. I would like to create log file for each command execution, Could some one advise how do we create log file.

Example Script:
Code:
###########################################################################
ORACLE_SID=ERS11G
ORACLE_HOME=/u03/app/oracle/product/11.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID ORACLE_HOME PATH LD_LIBRARY_PATH
###################################### Defining the Paths####################
SOURCETYPE=$1
INPUTFILESPATH=/ersdg3/ERS/TEST/RIO/files
BASEPATH=/ersdg3/ERS/TEST
ARCHIVEPATH=$BASEPATH/$SOURCETYPE/archive
CONTROLFILEPATH=$BASEPATH/$SOURCETYPE/control
AUDITFILENAME=${SOURCETYPE}_AUDIT_FILE.TXT
SOURCELOADER=${SOURCETYPE}_SOURCE_LOADER
AUDITCONTROLFILENAME=${SOURCETYPE}_REC_CNT.ctl
SOURCECONTROLFILENAME=$SOURCETYPE.ctl
SOURCECONTROLFILENAMENEW=${SOURCETYPE}_NEW.ctl
SOURCETABLENAME=ERS_${SOURCETYPE}_SRC
ARCHAUDITFILEPATH=${ARCHIVEPATH}/auditfiles
USERID=ETL_ERS
PASSWORD=ETL_ERS
SCHEMA=ERS11G
#####################################End of Paths###########################
cd $INPUTFILESPATH
################# Entry into Audit Table####################################
if [ -f *.LOG ]
        then
sqlplus -s -L ETL_ERS/ETL_ERS@ERS11G<<EOF
set feedback off heading off
#exec ETL_LOG.P_LOG_START_PROCESS(trunc(sysdate),'${SOURCELOADER}','ETL_SRC');
exit;
EOF
        else
                echo "Files doesnt exist"
                exit;
fi
####################End of Entry into Audit Table##########################
ls *.LOG >FILE.LIST
###################Check whether Audit file Exists#########################
if [ -f $AUDITFILENAME ]
    then
        rm $AUDITFILENAME
    else
        touch $AUDITFILENAME
fi
#########################################################################
while read filename
        do
##############Date Format for Sql Loader Script and for Directory Creation#####
        filename=$filename
        fname=${filename%%.*}
        date1=${fname##*_}
        date=`print $date1 |cut -c1-8`
        dat=`print $date |cut -c7-8`
        yr=`print $date |cut -c1-4`
        mon=`print $date |cut -c5-6`
        var01="Jan"
        var02="Feb"
        var03="Mar"
        var04="Apr"
        var05="May"
        var06="Jun"
        var07="Jul"
        var08="Aug"
var09="Sep"
        var10="Oct"
        var11="Nov"
        var12="Dec"
        val=$( eval eval echo \$var$mon )
        DATE="$dat-$val-$yr"
        dir=${SOURCETYPE}_${DATE}
echo $dir
############End of Date Format################################################
done <FILE.LIST

# 2  
Old 02-06-2013
Use exec > logfile 2> errorfile at the beginning of your script it would help Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print the specific part of the file name with file creation date?

Hello Folks, I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern. Filename: MobileProtocol.20171228T154200.157115.udr I want to get the count of files created on each day based on a pattern find. find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies

2. UNIX for Dummies Questions & Answers

Log File Creation

Hello :) This is my first post here. I am using MKS Toolkit for ksh and awk programming. The lines that are executed in ksh are shown with a '+' and the values are also shown in the console window. In case of awk, the interpretation/execution of every line is not available. Can you please... (2 Replies)
Discussion started by: Naveen_Hinduja
2 Replies

3. Shell Programming and Scripting

Help with creating a text file in perl with file creation date.

Hi, I am quite new to Perl scripting and i need to create a .TXT file using perl, with fields (A,B,C,D,E), and this text file should be named with current file creation date "XYZ_CCYYMMDD.TXT" (i.e.XYZ_2011042514:33 PM). Can anyone who has done this, please share their expertise on this... (5 Replies)
Discussion started by: msrahman
5 Replies

4. Solaris

Issue with log creation

Hi, some logs are not getting created under the required folder, which was working fine when i saw last time(15days back). Thought may be some issue with syslog deamon and did lot of R&D. Still not able to fix the bug.:wall: Is there any one to help me out ? Quick response will be appreciated.... (6 Replies)
Discussion started by: Sricharan21
6 Replies

5. Solaris

gzip a file and append creation date stamp to file

I want to gzip a file and append the creation date to the end of the file. How can I accomplish this task. Basically they are log files which need a creation date stamp appended to make sure they do not overwrite other log files. -jack (3 Replies)
Discussion started by: jacktravine
3 Replies

6. UNIX for Advanced & Expert Users

file creation

Hi, Is there any way to restrict directories with one type of file creation. regards. (8 Replies)
Discussion started by: guguli
8 Replies

7. UNIX for Dummies Questions & Answers

Regarding Cron log creation

Cameron, I have deleted the cron log file and create a new cron log file as the older was sucking up the disk space. now i have rescheduled the cron job but i dont see any logs on the newly created log file. I am confused what has happened. Can u help me out on this. (0 Replies)
Discussion started by: sanei05
0 Replies

8. Shell Programming and Scripting

file creation

hi guys Kindly see the below script #!/bin/bash if then # check to see if file notrouter exits or not if ! ls -l notrouter /root/joy/ >/dev/null then touch /root/joy/notrouter else echo "Entries already exist" fi else echo "Entries does not exist" fi here... (1 Reply)
Discussion started by: whizkidash
1 Replies

9. Shell Programming and Scripting

FTP and LOg file creation

Hello, I am new to unix , and I need to create a shell sciprt which helps me FTPing file from LAn to Unix box. These files r then processed using Perl script and put in a database. I also need to log the entire process of all the above methods in a log file in the same shell script. Like ,... (2 Replies)
Discussion started by: agarwalniru
2 Replies

10. Shell Programming and Scripting

Creation of log file under dynamic date folder

HI I want to create a date folder and then a log file under it, which will hold all output of shell script. Say shell script abc.sh runs every day and I want to redirect the output of abc.sh > /opt/bea/wls81/Pkmtest/$(date +%Y%m%d)/ant.log. Here date should always change according to system... (2 Replies)
Discussion started by: pankajkrmishra
2 Replies
Login or Register to Ask a Question