Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

currently my logrotate configuration adds a single number after the rotated log file:

mylogfile.log is rotated to mylogfile.log.1

I would like to change the extension to mylogfile.log.Current date

does anyone know a way to do this?

my log rotate code is :-

/usr/local/jboss/jboss-3.2.7-ND1/server/default/log/consolelog.log

{

copytruncate

rotate 1

missingok

notifempty

}

Currently am renaming the rotated file with script.is there any option to change the extension of log rotate default configuration. Please help me

is there any option to change the position of extension,for example mylogfile.log to mylogfile_currentdate.log.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Just add dateext option at the end (after your last option notifempty).

share|improve this answer
    
thanks for the reply.but i need the time in the extension. –  Jayakrishnan T Dec 27 '10 at 15:04
2  
@Jayakrishnan T: You can add seconds to the extension using dateformat. See man logrotate. –  Dennis Williamson Dec 27 '10 at 15:41
    
is there any option to change the position of extension,for example mylogfile.log to mylogfile_currentdate.log. –  Jayakrishnan T Dec 28 '10 at 4:05
add comment

i found the answer for this queation..The above code must change as shown below

Example:

/usr/local/jboss/jboss-3.2.7-ND1/server/default/log/consolelog.log {

copytruncate

rotate 1

missingok

notifempty

DATE=date +%F; mv /usr/local/jboss/jboss-3.2.7-ND1/server/default/log/consolelog.log /usr/local/jboss/jboss-3.2.7-ND1/server/default/log/consolelog_DATE.log

}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.