ansible-roles/elasticsearch/templates/rotate_elasticsearch_logs.j2
Bruno TATU a695bec780
All checks were successful
continuous-integration/drone/push Build is passing
Compress logs about garbage collector for elasticsearch
Whitout this improvement, this logs cannot be compressed:
/var/log/elasticsearch/gc.log.02
/var/log/elasticsearch/gc.log.29
/var/log/elasticsearch/gc.log.12
/var/log/elasticsearch/gc.log.18
2021-02-11 12:31:30 +01:00

10 lines
454 B
Django/Jinja

#!/bin/sh
# {{ ansible_managed }}
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