2017-11-14 11:07:06 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
LOG_DIR=/var/log/elasticsearch
|
|
|
|
USER=elasticsearch
|
|
|
|
MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }}
|
|
|
|
|
2021-04-01 15:30:38 +02:00
|
|
|
# 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
|