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