Date Not appending in log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Date Not appending in log file
# 1  
Old 01-24-2008
Date Not appending in log file

Hi experts . . .

Sunsolaris 9 version

I have the script as below:

Am getting log file as : archive_today_.log

Please suggest.

##################################################
set 'date'
dd=$3
mon=$2
export mon
yyyy=$6
export yyyy

cd /oracle/P47/saparch

LOG_FILE=/oracle/P47/saparch/archive_today_$date.log
echo "*******************************************************************">> $LOG_FILE

date >> $LOG_FILE

sqlplus "/as sysdba"<< EOF >> $LOG_FILE
set serveroutput on ;
set time on ;
recover automatic standby database;
CANCEL
exit
EOF

echo "Finish applying archives in SAP DR site..." >> $LOG_FILE

echo " ----------------------------------------------------------">> $LOG_FILE

echo "End SAP DR script " >> $LOG_FILE
echo "=========================================================" >> $LOG_FILE
.................................................................................................... .
# 2  
Old 01-24-2008
Hi,
Am I completely misunderstanding the problem here maybe? But the variable 'date' is never set anywhere ?!

Why not :
datestamp=$(date +'%d%m%Y')
LOG_FILE=/oracle/P47/saparch/archive_today_$datestamp.log
...
# 3  
Old 01-24-2008
Hi domivv,

thanks for reply . . . I modified like this:
#set 'date'
datestamp=$(date +'%d%m%Y')
dd=$3
mon=$2
export mon
yyyy=$6
export yyyy

cd /oracle/P47/saparch

LOG_FILE=/oracle/P47/saparch/archive_today_datestamp.log


I got following error:

archives_apply.sh: syntax error at line 11: `datestamp=$' unexpected
# 4  
Old 01-24-2008
Quote:
Originally Posted by vrjalli
Hi domivv,

thanks for reply . . . I modified like this:
#set 'date'
datestamp=$(date +'%d%m%Y')
dd=$3
mon=$2
export mon
yyyy=$6
export yyyy

cd /oracle/P47/saparch

LOG_FILE=/oracle/P47/saparch/archive_today_datestamp.log


I got following error:

archives_apply.sh: syntax error at line 11: `datestamp=$' unexpected
This is KSH syntax,You may try it with datestamp=`date +'%d%m%Y'`

Thanks
Nagarajan G
# 5  
Old 01-24-2008
Hi Nagrajan,

now script is like:

#set 'date'
datestamp='date +'%d%m%Y''
dd=$3
mon=$2
export mon
yyyy=$6
export yyyy

cd /oracle/P47/saparch

LOG_FILE=/oracle/P47/saparch/archive_today_datestamp.log


and output log file is:

archive_today_datestamp.log it is not picking date values. . .

rgds
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

2. UNIX for Dummies Questions & Answers

Appending Date at the end ONLY in first line of file

Hi, My requirement is to append a date in format DDMMYYYYHHMISS at the end of first line of file which is HEADER. I am trying command sed -i '1s/.*/&<date_format>/' <file_name> Where <date_format>=`date +%m%d%Y%H%M%S` I am somehow misisng the right quotes ti get this added in above... (2 Replies)
Discussion started by: sanjaydubey2006
2 Replies

3. UNIX for Dummies Questions & Answers

Appending date value mmdd to first column in file

Hi , I have a file with a running sequence number. I need to append a date value mmdd format on to the first column. for e.g.: The file contains records as 001 abc 002 cde 003 edf 004 fgh 005 hik The output should be 1111001 abc 1111002 cde 1111003 edf 1111004 ... (1 Reply)
Discussion started by: kalyansid
1 Replies

4. Shell Programming and Scripting

searching a log file and appending to a .txt file

I'm new to shell scripting and am writing a script to help me log the free memory and hd space on a server. As of now, the script just runs 'df -h' and appends the output to a file and then runs 'top' and appends the output to a log file. What I want to do, is have the script also search the... (3 Replies)
Discussion started by: enator45
3 Replies

5. UNIX for Dummies Questions & Answers

issue on reading the file and appending date

Hi Am having issue on appending time stamp I know the exact file names in the directory like a.dat b.dat c.dat e.dat f.dat I want to read all these file names and append the timestamp to each files like a.dat.20090604,b.dat.20090604 and move to the different directory. ... (3 Replies)
Discussion started by: bobprabhu
3 Replies

6. UNIX for Dummies Questions & Answers

Appending the current date on Copying the file.

Hi I have the data file in the one directory and i have to copy the file in the another directory with the timestamp. EX: /ab/cd/a.dat i need to copy this file to the another directory /ef/gh/. while am copying i need to append the current timestamp in the file like... (3 Replies)
Discussion started by: bobprabhu
3 Replies

7. Shell Programming and Scripting

appending date at the end of the file

I have file called xx Now i want to rename this file as xxYYYYMMDD_HHMIAM.xls Here is my code.. export DATE1=`date +%Y%m%d` mv xx xx$DATE1 This code renames as xxYYYYMMDD Now how can i append HHMIAM at the end of the file? Any help is appreciated... (3 Replies)
Discussion started by: govindts
3 Replies

8. Shell Programming and Scripting

Appending date

hi All, Searched forum but couldn't find a solution to this problem: How can I append a file with date in the ninth line? ie I want to insert a line with the current date and time in the ninth line. I tried this: date=`date` awk 'NR==9 {printf "'$date' \n"} {print $0}' abc.log below... (10 Replies)
Discussion started by: Sreejith_VK
10 Replies

9. Shell Programming and Scripting

Appending date to filename

hi i need to rename a.txt to a_12052008.txt using the batch file i used reanme a.txt a_%date%.txt ......but its done nothing am using win2000 professional edition. system date format is : The current date is: Mon 2008-05-12 can anyone help me to rename thanks aemu (5 Replies)
Discussion started by: aemunathan
5 Replies

10. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies
Login or Register to Ask a Question