Skip to content

Instantly share code, notes, and snippets.

@RamaRoberts
Created July 3, 2013 19:45
Show Gist options
  • Save RamaRoberts/5922093 to your computer and use it in GitHub Desktop.
Save RamaRoberts/5922093 to your computer and use it in GitHub Desktop.
Log rotation for MongoDB.
#!/bin/bash
LOGSDIR="/app/mongodb/logs"
# this causes mongo to rotate logs
killall -SIGUSR1 mongod
# now purge the older logs
logs=`find ${LOGSDIR}/ -type f -mtime +30`
for log in $logs; do
rm $log
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment