Log rotation

Hi All!

I seem to have a problem with log rotation, unless I am doing something wrong, I have type the following command for testing purposes to see if the

 -s 

option works but he did not:

 logadm -w /var/adm/messages -C 8 -c -s 512k -t '/var/adm/messages.$n' -z 1

the file is now at this size:

-rw-r--r--   1 root     root     146452271 Aug  5 08:56 messages

and did not create copies of the

messages

file as stated on the

logadm -w

command.

Please can I have some help

Check /etc/logadm.conf to see, if the entry was written correctly and check root's crontab, if the /usr/sbin/logadm cronjob ist still there.

It has, I have used the

logadm -V

command to check

Did the logadm-cronjob run after you made your modification? This is not clear in your post. The statement you posted only updates the config file but does not perform any actions.

You can also try to run logadm manually with the verbose switch on:

logadm -v

Hi!

After running

logadm -v

it created another file

messages.0

and compressed

messages.1

, but now current messages file is bigger that 512K set

-s 512k

.
Should�nt that file after reaching 512k being automatically renamed to

message.0

and created a new

message

file?

I am not sure, if it is necessary to send a SIGHUP to syslog when using the copy-truncate-option ( -c ). You might give it a try. Add -a 'kill -HUP `cat /var/run/syslog.pid`' to the commandline.

-a 'kill -HUP `cat /var/run/syslog.pid`' is necessary, because syslogd needs to close and re-open its file handle.
-c does not break anything - but slows things down.

1 Like

Not necessarily, if the logfile is opened with O_APPEND. The OP uses -c to truncate the logfile. So the inode stays the same and if the file is opened with O_APPEND, then it should be written starting with byte 1.

But if syslog does not use O_APPEND, then the filepointer stays at an offset of some 500k and continues to write from here, resulting in a sparse file. In this case the SIGHUP is needed.