Logs are not getting compressed

Httpd log files are getting rotated but not getting compressed

Package httpd-core (in el9) provides file /etc/logrotate.d/httpd, which contains:

# Note that logs are not compressed unless "compress" is configured,
# which can be done either here or globally in /etc/logrotate.conf.
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}

The “not getting compressed” is thus intentional, and the note tells how to change that.

yes, I want only httpd logs to be compressed, so I configured “compress” in /etc/logrotate.d/httpd file, please find below configuration files

cat /etc/logrotate.d/httpd

# Note that logs are not compressed unless "compress" is configured,
# which can be done either here or globally in /etc/logrotate.conf.
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    compress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}
cat /etc/logrotate.conf

# see "man logrotate" for details

# global options do not affect preceding include directives

# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# system-specific logs may be also be configured here.

This above configuration I made on one server and it is working fine as excepted, but on other servers https logs are getting rotated but not compressing, please help on this

You did change the config of one server and its behaviour did change.
Did you change the config of the other servers?

yes, configured same configuration on some servers, but only on one server it is working as excepted

There is no issue on gzip, as I tried to zip the httpd logs manually, that also working fine

There is a reason for delaycompress!! The file is not always freed up when logrotate kicks in. The httpd process potentially is still writing to it! So, i suggest to not change this!

how come for one server it is working fine, as there is no delaycompress configured only compress configured

The “not always” and “potentially still” should hint that these things are not perfectly repeatable and thus the “working fine” was mere luck.

ohh okay, then I want to try with configuring “delaycompress” for those servers ? will that work ?

Hello support team, could anyone please reply on this?

First, note that the members of this forum are a community. Peer support. Yes, some members are more involved in build of AlmaLinux, but most – like myself – are users, like yourself. None of us is here to discuss 24/7.

The only thing that I know about logrotate is where to look for its configuration (and what @Daca wrote).

The logrotate, like most packages is an “upstream project”. It might be in every Linux distro. Granted, Red Hat has chosen specific version of it and may have tuned default config for RHEL. AlmaLinux OS is compatible with RHEL and hence most of RHEL documentation is valid for AlmaLinux OS too and the user community of RHEL, CentOS Stream, (and other Enterprise Linux distros) knows logrotate as well as we do.


I cannot tell whether it will “work”, but trying such config should be easy and safe (as in will not wreck the entire system).


PS. This forum has code tags (the </> button) for neater format of shell output and other text files. As you should notice from your post the hashtag has other effect on markdown (outside of code block).

delaycompress and compress both are not working now, could you please help on this