ansible-roles/mongodb-org-3.2/templates/mongo_log_rotate.sh.j2

15 lines
353 B
Plaintext
Raw Normal View History

2016-01-27 16:21:18 +01:00
#!/bin/bash
MONGO_PID_FILE={{ mongodb_dbpath }}/mongod.lock
LOG_RETAIN_DAYS={{ mongodb_log_retain_days }}
RETVAL=
MONGO_PID=$( cat $MONGO_PID_FILE )
# Tell mongo to rotate its log file
kill -SIGUSR1 $MONGO_PID
RETVAL=$?
# Remove the old log files
find {{ mongodb_logdir }} -name "{{ mongodb_log_file }}.*" -ctime +$LOG_RETAIN_DAYS -exec rm -f {} \;