Would reduce unnecessary disk space from log files in your system if you use LogRotate. On this post-configure MongoDB log files, site MongoDB 3.0 you can change the behaviour logRotate parameter for MongoDB. If you use copy truncate works pretty well for log rotation.
First you have to update in mongoDB configure file /etc/mongod.conf.
systemLog:
logAppend: true
logRotate: reopen
Then, you can use this logrotate configuration: /etc/logrotate.d/mongodb
/var/log/mongodb*.log {
daily
rotate 30
size 50M
compress
dateext
missingok
notifempty
sharedscripts
postrotate
/bin/kill -SIGUSR1 `cat /var/lib/mongodb/mongod.lock 2> /dev/null` 2> /dev/null || true
endscript
}
Use below command, If you would check immediately whether above config file is working good.
# logrotate -f /etc/logrotate.d/mongodb
Comments (0)