Tomcat log file in date format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tomcat log file in date format
# 1  
Old 09-13-2011
Tomcat log file in date format

Hi,

I was asked to write a new logrotate file for tomcat logs..in which one
of the requirement is to have date and time appended at the end of
the file name.

I have tried dateext and dateformat-%Y-%m-%d-%s but these directives
didn't have the option for HH:MM.

I am very new to this logrotate... I think some scripting in logrotate
might be needed but I am very bad at scripting. Can anyone please tell
me how to get the requirement satisfied.

---------- Post updated 09-13-11 at 04:59 AM ---------- Previous update was 09-12-11 at 02:35 PM ----------

please respond... i need ur help still
# 2  
Old 09-13-2011
Quote:
Originally Posted by sdspawankumar
I have tried dateext and dateformat-%Y-%m-%d-%s but these directives
didn't have the option for HH:MM.
If you really want "HH:MM" you can use:
Code:
date +"%R"

I would suggest not having special characters ":" in your file name.

If you want a date and time you can use:
Code:
date +"%Y%m%d%H%M"

# 3  
Old 09-14-2011
Thanks shell.Can you tell me the reason why ":" should not be used in filename because it comes by default when using %R or %T.

I tried with that in the script with
Code:
date=`date +%R`;
mv -f /var/log/dtomcat/catalina.out.1.gz /var/log/dtomcat/catalina.out.$date.gz...

Now the problem is this script works when executed in a seperate file...but when the same script is embedded between postrotate and endscript...its not working... please anyone tell me the reason why its doing like that...and what to be modified to get my script execute

Last edited by Franklin52; 09-14-2011 at 09:25 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Changing Date format for su log

Need to view su log with year in the time stamp. Only mm/dd format is showing up in the logs. Any help please ..:( (2 Replies)
Discussion started by: Chandru1
2 Replies

2. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

3. Shell Programming and Scripting

Monitor log entries in log files with no Date format? - Efficient logcheck?

is there a way to efficiently monitor logfiles that do not have a date or time format? i have several logs on several different servers that need to be monitored. but i realized writing a script for this would be very complex and time consuming giving the variety of things i need to check for i.e.... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. 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

5. Shell Programming and Scripting

Tomcat Monitoring log file

Hi, I ned to monitor the tomcat log file called "catalina.out" for "OutOfMemory" ,"java.sql.SQLException" and "Error" error. the script should monitor this file (catalina.out) and send us the mail as soon as it finds the string "Out of memory" or "java.sql.SQLException" or "Error" in the... (2 Replies)
Discussion started by: mnmonu
2 Replies

6. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

7. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

8. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

10. UNIX for Advanced & Expert Users

file date format

ls -l doesn't return the date of a file in a numerical format Is there an other command to retrieve the date of an existing file in one of the following formats YYYYMMDD or MMDDYYY ? (4 Replies)
Discussion started by: ludenso
4 Replies
Login or Register to Ask a Question