View Full Version : [ubuntu] about logrotate script

December 17th, 2010, 01:25 AM
HI~ I hava a question about logrotate.

in logrotate script, usually there are a lot of postrotate script like this

/etc/init.d/XXXXX restart(or kill -HUP syslogd)

what is the reason that restart the process after making new logfile?
And is that necessary?

thanks for reading.

December 18th, 2010, 06:09 PM

This is because the old file is moved in the directory tree, but this doesn't change its physical position in the drive. So programs would not even notice the file was moved and they would continue to append their output to the moved file and the new one would stay empty. At least it is something of this kind.
Therefore the servers have to re-open their log connections to write to the new files.

If the program cannot be told to re-open the log file, you can use "copytruncate" which will copy and empty the log instead of creating a new one.