Skip to content

Instantly share code, notes, and snippets.

@srpouyet
Created February 29, 2012 17:14
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save srpouyet/1942579 to your computer and use it in GitHub Desktop.
Save srpouyet/1942579 to your computer and use it in GitHub Desktop.
Mongodb logrotate on Ubuntu
# Put this in /etc/logrotate.d/mongodb
# http://stackoverflow.com/questions/5004626/mongodb-log-file-growth
/var/log/mongo/*.log {
daily
rotate 30
compress
dateext
missingok
notifempty
sharedscripts
postrotate
/bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
endscript
}
@fdrouet
Copy link

fdrouet commented Jun 5, 2013

on ubuntu 12.04 with mongodb 2.4.3 you should change your path for the logs and lock files :

- /var/log/mongo/*.log {
+ /var/log/mongodb/*.log {

...

-   /bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
+   /bin/kill -SIGUSR1 `cat /var/lib/mongodb/mongod.lock 2> /dev/null` 2> /dev/null || true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment