logrotate notes

Logrotate notes.





The logrotate directions for a daemon named app put at /etc/logrotate.d/app.
# cat /etc/logrotate.d/app

/logs/app/gen.log {
    daily
    missingok
    rotate 7
    compress
    copytruncate
    notifempty    
}

/logs/app/sec.log {
    weekly
    mail administratotator@sys.ipduh.com
    missingok
    rotate 4
    shred
    create 640 app app
}




Directives explanation ( from the manual ).
daily, weekly , monthly 
  Handle time period
  (The handling trigger may be the file size) 

missingok
  If the log file is missing, go on to the next one without issuing an error message.

rotate count
  Log files are rotated count times before being removed or mailed to the address specified in a mail directive. 
  If count is 0, old versions are removed rather than rotated.

compress
  Old versions of log files are compressed with gzip(1) by default.

copytruncate
  Truncate  the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one.
  It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever.
  Note that  there  is a very small time slice between copying the file and truncating it, so some logging data might be lost.  When this option is used, the create option will
  have no effect, as the old log file stays in place.

notifempty
  Do not rotate the log if it is empty (this overrides the ifempty option).

create mode owner group
  Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the  log  file  just  rotated).   mode
  specifies  the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the
  group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will  use  the  same
  values as the original log file for the omitted attributes.

shred  
  Delete  log  files  using  shred -u instead of unlink().  This should ensure that logs are not readable after their scheduled deletion; this is off by
  default.  See also noshred.









Run now (to test) logrotate directions for app.
# logrotate --force app


Debug logrotate directions for app.
# logrotate --force --debug app




Logrotate Notes