Rotate the sysutils/automount Log File


14:12 | 1 Comments


The sysutils/automount port is quite useful for automounting removable
storage and ofers a lot of helpful information in its /var/log/automount.log log file,
but it can grow quite large in size after heavy usage.

# du -sh /var/log/automount.log
340M    /var/log/automount.log

To make FreeBSD's newsyslog(8) it auto-rotate it we need to add it to the
/etc/newsyslog.conf config file as below.

# echo '/var/log/automount.log 644 7 100 @T00 JC' >> /etc/newsyslog.conf

Now we should restart the newsyslog(8) daemon ...

# /etc/rc.d/newsyslog restart
Creating and/or trimming log files.

... and trigger trim of the /var/log/automount.log file.

# newsyslog -v
Processing /etc/newsyslog.conf
/var/log/all.log <7J>: does not exist, skipped.
/var/log/amd.log <7J>: does not exist, skipped.
/var/log/auth.log <7J>: --> will trim at Tue Dec 31 23:00:00 2013
/var/log/console.log <5J>: does not exist, skipped.
/var/log/cron <3J>: size (Kb): 44 [100] --> skipping
/var/log/daily.log <7J>: does not exist, skipped.
/var/log/debug.log <7J>: size (Kb): 71 [100] --> skipping
/var/log/kerberos.log <7J>: does not exist, skipped.
/var/log/lpd-errs <7J>: size (Kb): 1 [100] --> skipping
/var/log/maillog <7J>: --> will trim at Thu Jun 27 00:00:00 2013
/var/log/messages <5J>: --> will trim at Tue Dec 31 23:00:00 2013
/var/log/monthly.log <12J>: does not exist, skipped.
/var/log/pflog <3J>: does not exist, skipped.
/var/log/ppp.log <3J>: size (Kb): 53 [100] --> skipping
/var/log/security <10J>: size (Kb): 1 [100] --> skipping
/var/log/sendmail.st <10>:  age (hr): 62 [168] --> skipping
/var/log/utx.log <3>: --> will trim at Mon Jul  1 05:00:00 2013
/var/log/weekly.log <5J>: does not exist, skipped.
/var/log/xferlog <7J>: size (Kb): 1 [100] --> skipping
/var/log/automount.log <7J>: size (Kb): 348293 [100] --> trimming log....
Signal all daemon process(es)...
Notified daemon pid 1046 = /var/run/syslog.pid
Pause 10 seconds to allow daemon(s) to close log file(s)
Compress all rotated log file(s)...

Now the file size is more 'normal' and will never grow that much size in time.

# du -sh /var/log/automount.log
1.0k    /var/log/automount.log

The rotated old log is also compressed.

# ls -lh /var/log/automount*
-rw-r--r--  1 root  wheel    76B 2013.06.26 13:46 /var/log/automount.log
-rw-r--r--  1 root  wheel    12M 2013.06.26 13:46 /var/log/automount.log.0.bz2




Anonymous harry wilson | 3/24/2015 8:31 AM  
Very Nice blog! Great Resources. Also, Try Docufreezer for Batch Conversion from PDF to DOC and other formats. Download DocuFreezer at http://www.docufreezer.com

Post a Comment