Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Looking for logrotate in FreeBSD? Use newsyslog.conf!
Wednesday - May 7th 2014 - by - (0 comments)

 

On a dedicated web server an access log was written to a non-default path, filling up slowly but surely the disk space. After a manual verification I saw that the log file was never rotated:

stat example.com_combined.log
88 306985 -rw-r--r-- 1 root wheel 1251416 3125313490 "Nov 12 22:11:51 2013" "May  7 08:44:38 2014" "May  7 08:44:38 2014" "May 10 22:05:05 2012" 16384 6107168 0 example.com_combined.log

Meaning that this file was first created on May 10th 2012 - almost two years ago.

In my Linux habit, I wanted to check out logrotate.conf, but as this is a FreeBSD system, logrotate does not exist. Instead the log rotation can be configured in /etc/newsyslog.conf.
I added the following line:

# logfilename [owner:group] mode count size when  flags [/pid_file] [sig_num]
/usr/home/log/example.com_combined.log  644 12 * $W0D23 J /var/run/httpd.pid 30

This line explained in short:

/usr/home/log/example.com_combined.log -> The file to rotate
644 -> The permissions the file should have after rotation (chmod)
12 -> Keep 12 rotated versions
* -> Don't worry about the size
$W0D23 -> Rotate the log file weekly on the 0th day (Sunday) at 23:00
J -> Use compression on the rotated log file (bz2)
/var/run/httpd.pid -> The file holding the process ID writing into this log file
30 -> Send the SIGNAL 30 (SIGUSR1) to the PID (in this case Apache), causes a reload

For further and more detailed explanation, check out the FreeBSD man page for newsyslog.conf.

 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6937 Days
until Death of Computers
Why?