I'm trying to configure logrotate
to rotate and delete log files every day at midnight, but have never used it before. So: (a) I want to confirm that my configuration is correct, and (b) I need help getting on automating its daily execution at midnight.
My software produces a large log file at /abs/path/to/log/myapp-log.txt
. Here's what I'd like to happen:
- Timestamp every log file with the date extension in its name
- Only have 1 log file in
/abs/path/to/log/
at any point in time; so every time the log is rotated and a new log file is created, delete the old one
logrotate.conf
:
/abs/path/to/log/myapp-log.txt {
daily
copytruncate
create 700 myUser myGroup
dateext
maxage 1
missingok
}
A few things I'm unsure of here:
- Do I need to specify
daily
if I'm specifying amaxage
of 1? - What exactly is
missingok
doing? Something about ignoring a system warning if a log file isn't there? What happens if I don't specifymissingok
and the log file isn't there? - Do I even need
copytruncate
if I'm specifyingdaily
/maxage 1
? These three settings feel a little redundant, but not sure what role each one plays.
Second, how do I ensure this gets run every day at midnight? Cron? I only ask because I read somewhere that /etc/cron.daily/logrotate
runs automatically every day, but not sure how that is configurable. Thanks in advance.