Apache httpd log rotation does not compress the logs

A CentOS 7 installation with a simple yum install of httpd also creates a logrotation script.  The script does log rotate files, however, there is no compression.  A quick look at the script indicates that some compression settings are put into place, but as experience indicates, not enough to do the job.

By default, this is the logroation script as found /etc/logrotation.d/httpd. Notice that delaycompress option is implemented. According to the man page for logrotate, delaycompress will “[p]ostpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with compress. It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time.”  That explains why log rotation is not compressing the logs during rotation.  The option compress should be implemented.

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}

The logs looked something like this with this implementation of the httpd logrotation script.

-rw-r--r--. 1 root root    479262 May 29 15:58 access_log
-rw-r--r--. 1 root root   2424379 May 28 03:30 access_log-20180528
-rw-r--r--. 1 root root      4096 May 29 15:58 error_log
-rw-r--r--. 1 root root      1172 May 28 03:30 error_log-20180528
-rw-r--r--. 1 root root 112509696 May 29 15:58 ssl_access_log
-rw-r--r--. 1 root root  80638579 May 28 03:30 ssl_access_log-20180528
-rw-r--r--. 1 root root     88304 May 29 15:58 ssl_error_log
-rw-r--r--. 1 root root    640238 May 28 03:01 ssl_error_log-20180528
-rw-r--r--. 1 root root 146174720 May 29 15:58 ssl_request_log
-rw-r--r--. 1 root root 107801351 May 28 03:30 ssl_request_log-20180528

Here is my revised script.  Aside from the additional options of rotate and daily, I have elected to use compress without the delaycompress option.

/var/log/httpd/*log {
    rotate 30
    daily
    missingok
    notifempty
    sharedscripts
    compress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}

Revised (6/11/2018)
By going this route, the rotation occurs on a default of a weekly basis rather than the daily override.

/var/log/httpd/*log {
    rotate 5
    missingok
    notifempty
    sharedscripts
    compress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}

After modifying the script, the script was tested using logrotate -d to debug, then to force the run of the script, logrotate -f.  An interesting result of forcing the logrotation is the creation of compressed and rotated log files that looked like this access_log.1.gz rather than what I expected access_log-20180528.gz.  There may be an explanation for that.  The force option was needed to complete the script, since the script had already been executed that day.  By allowing the script to run on its own for a day, the result for rotation with compression was access_log-20180530.gz as expected.