Elasticsearch: daily job for log rotation
parent
bcbfcf9080
commit
4746354c54
@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: "log rotation script"
|
||||
template:
|
||||
src: rotate_elasticsearch_logs.j2
|
||||
dest: /etc/cron.daily/rotate_elasticsearch_logs
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0750"
|
@ -0,0 +1,9 @@
|
||||
#!/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.????-??-??" -exec gzip --best {} \;
|
||||
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??.gz" -mtime +${MAX_AGE} -delete
|
Loading…
Reference in New Issue