#!/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./bin
backpath=/data/backup/
echo "rs.slaveOk();db.runCommand({logRotate:1});" >/tmp/logappend.js
chmod /tmp/logappend.js
/usr/local/mongo/bin/mongo --port -u "root" -p "MANAGER" --authenticationDatabase "admin" admin /tmp/logappend.js
mv /data/mongodb/replset/mongod.log.* $backpath
find $backpath -mtime + -name "mongod.log.20*" -exec rm -rf {} \;