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

15 lines
353 B
Django/Jinja

#!/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 {} \;