#!/bin/bash #Rotate the MongoDB logs to prevent a single logfile from consuming too much disk space. #app=mongod #mongodPath=/root/mongodb-linux-x86_64-rhel62-3.5.10/bin backpath=/data/backup/ echo "rs.slaveOk();db.runCommand({logRotate:1});" >/tmp/logappend.js chmod 755 /tmp/logappend.js /usr/local/mongo/bin/mongo --port 27017 -u "root" -p "MANAGER" --authenticationDatabase "admin" admin /tmp/logappend.js mv /data/mongodb/replset/mongod.log.20* $backpath find $backpath -mtime +3 -name "mongod.log.20*" -exec rm -rf {} ;