Install Logrotate on FreeBSD.

1. Install logrotate

#cd /usr/ports/sysutils/logrotate

#make install clean

2. Configure logrotate

#mkdir /usr/local/etc/logrotate.d

#cp /usr/local/etc/logrotate.conf.sample /usr/local/etc/logrotate.conf

3. Configure logrotate for mongodb log.

#vi /usr/local/etc/logrotate.d/mongod

 

#path to mongodb log file.

/data/db/mongodb/logs/mongodb.log {

daily

rotate 10

size 10M

copytruncate

compress

extension gz

missingok

notifempty

}

4. Configure logrotate for MySQL.

#vi /usr/local/etc/logrotate.d/mysqld

#path to mysql log file.

/data/db/mysql/logs/mysqld.log {

daily

rotate 20

size 50M

copytruncate

delaycompress

compress

extension gz

missingok

notifempty

}

5. Make schedule to run logrotate every day.

#vi /etc/crontab

0       1       *       *       *       root    /usr/local/sbin/logrotate /usr/local/etc/logrotate.conf > /dev/null 2>&1

6. Restart cron.

#/etc/rc.d/cron restart

Be the first to comment

Leave a Reply