Looking for logrotate in FreeBSD? Use newsyslog.conf!

Written by - 0 comments

Published on - Listed in BSD Unix


 

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.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences