I have a log file ircd.log
in /home/irc
.
I want to rotate it daily at 00:00 and keep 7 days.
I want the rotated log files to be saved as ircd.log.YYYYMMDD
for example ircd.log.20140505
.
Can someone please tell me the package to use and also an example configuration for it based on this? Also is it possible to store this configuration at the user level?
Best Answer
As @bain mentioned, the package is called
logrotate
. To rotate this file as you have mentioned, you could use the following configuration in/etc/logrotate.d/irc
:A breakdown of the configuration options:
daily
option tellslogrotate
to process this file every day when it is run.rotate 7
option tells it to keep 7 copies.compress
option tells it togzip
the old files.missingok
tellslogrotate
not to complain if it is missing.create
tells the mode, owner, and group to use when creating files.su
changes the user who runs the compression, etc, so you may not want to include it