Now my requirement is to compress all the log files and keep only last 5 days compressed logfiles always.
For ex:
If today is 10/09/2009 ( mm/dd/yyyy)
then my log directory ( /var/log/appn) should looks like,
tomcat_access_log.2009-10-09.log
tomcat_access_log.2009-10-08.log.gz
tomcat_access_log.2009-10-07.log.gz
tomcat_access_log.2009-10-06.log.gz
tomcat_access_log.2009-10-05.log.gz
tomcat_access_log.2009-10-04.log.gz
I tried to get it done using logrotate, but I couldn't.
It is really thankful, if you give, even some other mechanism to compress and keep only last 5 days logs.
Bumping up posts or double posting is not permitted in these forums.
Please read the rules, which you agreed to when you registered, if you have not already done so.
You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future
Thank You.
The UNIX and Linux Forums.
---------- Post updated at 14:20 ---------- Previous update was at 14:18 ----------
To keep logrotate from creating or truncating the original logs, set these options:
nocreate
nocopy
nocopytruncate
which are all described in the man page:
nocopy Do not copy the original log file and leave it in place. (this
overrides the copy option).
nocopytruncate
Do not truncate the original log file in place after creating a
copy (this overrides the copytruncate option).
nocreate
New log files are not created (this overrides the create
option).