11 Jul 2020, 00:00

Logrotate

Share

Doc ubuntu

Config de la rotation stockée dans /etc/logrotate.d/mon-journal-a-rotater

De cette forme :

/path/to/my/logfile {
	monthly        # can be daily, weekly
	rotate 12      # keep 12 history files
	compress       # gzip the old logs
	delaycompress  # gzip old logs except the more recent one
	missingok      # does not stop if a file is missing
	notifempty     # does not rotate if file is empty
	create 644 root root # permissions, user and group for the newly created file
}

Pour Docker :

/var/lib/docker/containers/*/*.log {
  rotate 30
  daily
  compress
  size=10M
  missingok
  delaycompress
  copytruncate  # does not replace, but truncate the file, so the the docker process is not disturbed by a missing file
}

Force rotation :
logrotate -fv /etc/logrotate.d/mon-journal-a-rotater (force, and verbose)
On peut spécifier directement le fichier de configuration général, /etc/logrotate.conf, qui inclue tout ce qui se trouve dans /etc/logrotate.d/ si on veut rotater l’ensemble des logs.