elasticsearch: log rotation is more readable/maintainable

This commit is contained in:
Jérémy Lecour 2021-04-01 15:30:38 +02:00 committed by Jérémy Lecour
parent 33837844ee
commit 7041a70eeb
2 changed files with 9 additions and 2 deletions

View File

@ -28,6 +28,7 @@ The **patch** part changes incrementally at each release.
* apache: deny requests to ^/evolinux_fpm_status-.*
* certbot: use a fixed 1.9.0 version of the certbot-auto script (renamed "letsencrypt-auto")
* cerbot: use the legacy script on Debian 8 and 9
* elasticsearch: log rotation is more readable/maintainable
* evoacme: upstream release 21.01
* evolinux-users: Add sudo rights for nagios for multi-php lxc
* listupgrade: update script from upstream
@ -145,6 +146,7 @@ The **patch** part changes incrementally at each release.
* certbot: fix haproxy hook (ssl cert directory detection)
* certbot: install certbot dependencies non-interactively for jessie
* elasticsearch: configure cluster with seed hosts and initial masters
* elasticsearch: log rotation is more readable/maintainable
* elasticsearch: set tmpdir before datadir
* evoacme: read values from environment before defaults file
* evoacme: update for new certbot role

View File

@ -5,5 +5,10 @@ LOG_DIR=/var/log/elasticsearch
USER=elasticsearch
MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }}
find ${LOG_DIR} -type f -user ${USER} \( -name "*.log.??" -o -name "*.log.????-??-??" -o -name "*-????-??-??.log" \) -not -name "*.gz" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} \( -name "*.log.??.gz" -o -name "*.log.????-??-??.gz" -o -name "*-????-??-??.log.gz" \) -ctime +${MAX_AGE} -delete
# Compress logs
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} -name "*-????-??-??.log" -exec gzip --best {} \;
find ${LOG_DIR} -type f -user ${USER} -name "*.log.??" -not -name "*.gz" -exec gzip --best {} \;
# Delete old logs
find ${LOG_DIR} -type f -user ${USER} -name "*gz" -ctime +${MAX_AGE} -delete