rotate_httpd_error_log_meg

Version 1.514

Feature
Finished

To apache/nginx error logs from getting too large in a run-away case, new variable that lets the dataskq check the size of these logs, and rotate them if needed. Internal default: rotate_httpd_error_log_meg=0 to keep the domain.com.error.log files with a certain range, set that number in the rotate_httpd_error_log_meg setting. So if you want a log rotate out at 1gig, you'd set it to 1024 Meg, eg: rotate_httpd_error_log_meg=1024 ---- Also add option to truncate, instead of rotate: rotate_httpd_error_log_truncate=0|1 internal default will be 1. If this is set, then the truncation will create a new log 1/2 the size of the original (half of rotate_httpd_error_log_meg) We use 1/2 because if you were to truncate to size X, then as the log grows, the truncation would happen every minute which would be a very large burden on the disk I/O. A truncation to a specific size requires: - fseek to location at 1/2 the size of the log - go forwards byte by byte until you hit the first newline character, then go 1 more. - read each line from the current position, and write to a new log. - re-open the current log from where the end used to be, and continue read/writing, because new data might have been added - delete the old log, rename the new one to the old name, and HUP apache/nginx. If rotate_httpd_error_log_meg=0 is set, the rotate_httpd_error_log_truncate value has no effect. ------- If this event is triggered, a notice will be sent to the User and the Admins on the system with a Notice that a large log has been rotated/truncated. The last 5 lines of the log will be included, either way. No template for this message currently exists, and the line numbers cannot currently be changed. If anyone needs the ability to adjust these, let us know. ===== EXAMPLE #1 rotate_httpd_error_log_meg=1024 rotate_httpd_error_log_truncate=0 Every minute the dataskq will check all logs at: /var/log/httpd/domains/*.error.log (or nginx) If any of those logs is greater than 1024 meg, the log is reset to 0 and HUP sent to httpd. This is very fast, and doesn't cause any excessive disk I/O. Drawback is Users cannot see previous errors, but chances are, it will fill up quickly again anyway. ===== EXAMPLE #2 rotate_httpd_error_log_meg=1024 rotate_httpd_error_log_truncate=1 Every minute the dataskq will check all logs at: /var/log/httpd/domains/*.error.log (or nginx) If any of those logs is greater than 1024 meg, the dataskq copies the last 512Meg to a new file. It deletes the big log, renames the new log to the old name, and sends an HUP to httpd. ==== NOTICES New directadmin.conf internal default: rotate_httpd_error_log_notify=3 if you wish to disable the noticed, set this value to 0. At the moment, 1 and 2 are reserved for future just user or just admin, but are not implemented. Use 0 or 3 at this time.

Interested to try DirectAdmin? Get a 30-day Free Trial!