Operating System - HP-UX
1844060 Members
3326 Online
110227 Solutions
New Discussion

Log Rotate does not rotate log files

 
Ashish Palkhiwala
Occasional Advisor

Log Rotate does not rotate log files

I have downloaded and installed logrotate from following link.

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/logrotate-2.5/

Following is my conf file content.
-----------------------------------------------
/opt/logrotate/conf# more logrotate.conf
# Sample log rotate configuration file.

errors root
compress
create

# syslog.log file rotation
/var/adm/syslog/syslog.log {
rotate 5
daily
postrotate
/sbin/killall -HUP syslogd
endscript
}

# mail.log rotation
/var/adm/syslog/mail.log {
rotate 5
daily
postrotate
/sbin/killall -HUP syslogd
endscript
}
----------------------------------------------

I have a cron job which runs logrotate every night. but everyday I get following email. and nologs are rotated.



reading config file /opt/logrotate/conf/logrotate.conf
reading config info for /var/adm/syslog/syslog.log
reading config info for /var/adm/syslog/mail.log
Handling 2 logs
rotating pattern: /var/adm/syslog/syslog.log after 1 days (5 rotations)
empty log files are rotated old logs are removed
errors will be mailed to root
rotating file /var/adm/syslog/syslog.log
log does not need rotating
rotating pattern: /var/adm/syslog/mail.log after 1 days (5 rotations)
empty log files are rotated old logs are removed
errors will be mailed to root
rotating file /var/adm/syslog/mail.log
log does not need rotating


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

/opt/logrotate/bin/logrotate -d /opt/logrotate/conf/logrotate.conf


What am I missing?

Thanks
Ashish
3 REPLIES 3
Todd McDaniel_1
Honored Contributor

Re: Log Rotate does not rotate log files

I have a few observations first...

I guess my first question is why are you rotating your syslog and mail log every day? and why are you rotating out logs every 5 days?

Seems a bit over managed...

Seems I have pretty active boxes and once a month reboots generates a OLDsyslog.log and a new syslog.log giving me 2 months worth of syslog and mail log...


_____________________________________________________
You can do this easier... with this in the script. No need to do -HUP at all.

I think that is where you are hanging.


cp syslog.log to oldsyslog.log
> syslog.log
Unix, the other white meat.
Ashish Palkhiwala
Occasional Advisor

Re: Log Rotate does not rotate log files

Thanks for your input.

This is test that I have set up on our test server. To actually see logs being rotated, I have set it up for daily rotation.

Once I have it working properly I will change the frequency and save time.

Did not understand your comment about script. Are you saying I do not need postscript at all?

My main issue is, why does it says "log does not need rotating" ?

Thanks
Ashish
Todd McDaniel_1
Honored Contributor

Re: Log Rotate does not rotate log files

I have never used that script, but it is much easier to do this than that script makes it.

Just make a cron script do an arbitrary cp of the log file every X days. Might be a bit simplistic but it shouldn't be hard.

cp syslog.log.bak3 syslog.log.bak4
cp syslog.log.bak2 syslog.log.bak3
cp syslog.log.bak1 syslog.log.bak2
cp syslog.log syslog.log.bak1
> syslog.log


hehe... I agree with the script output. "Your log does not need to be rotated".

Im still not sure the business reason you are doing this. Other than to sharpen your scripting skills.
Unix, the other white meat.