If you downloaded the FirstWave VM then the mongod.conf for logrotate is already in place for you and maybe you just need to modify the settings. Otherwise the steps and sample are below.
Note: You can find all of your logrotate configuration files in /etc/logrotate.d/, Logrotate is a job ran daily by cron
There are a few options you should look at before making your configuration file: Logrotate Man page. Considerations include:
vi /etc/logrotate.d/mongod.conf
# Replace /var/log/mongodb/mongod.log with your log location (step 1) if different /var/log/mongodb/mongod.log { weekly maxsize 500M rotate 50 missingok compress delaycompress notifempty create 640 mongod mongod sharedscripts postrotate kill -SIGUSR1 $(pidof mongod) >/dev/null 2>&1||: endscript } |
Thats it! It is advised to revisit your logs after a few cycles (Days or Weeks) to ensure your operating as expected and make any tweaks that you see fit.