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:
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.
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Container Containers CouchDB DB DNS Database Databases Docker ELK ElasticSearch Elasticsearch Filebeat FreeBSD GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Icingaweb2 InfluxDB Internet Java KVM Kibana Kubernetes LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher SSL Security Shell SmartOS Solaris Surveillance SystemD TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder