Skip to content

Instantly share code, notes, and snippets.

@advancedxy
Created December 8, 2013 13:06
Show Gist options
  • Save advancedxy/7857161 to your computer and use it in GitHub Desktop.
Save advancedxy/7857161 to your computer and use it in GitHub Desktop.
logrotate config file for mongodb
/path/to/configsvr/config.log{
weekly
rotate 9
compress
size 100M
sharedscripts
create
postrotate
/bin/kill -SIGUSR1 `cat /path/to/configsvr/mongd.lock 2> /dev/null` 2> /dev/null || true
/bin/find /path/to/configsvr/ -type f -size 0 -regextype sed -regex ".*\.log\.[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}" -delete 2> /dev/null
true
endscript
}
/path/to/mongos/mongos.log{
weekly
rotate 9
compress
size 100M
create
sharedscripts
postrotate
/usr/bin/pkill -SIGUSR1 mongos || true
/bin/find /path/to/mongos/ -type f -size 0 -regextype sed -regex ".*\.log\.[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}" -delete 2> /dev/null
true
endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment