Author Topic: Logrotate did not generate the rotated log file  (Read 1475 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Logrotate did not generate the rotated log file
« on: September 20, 2025, 01:07:45 AM »
Logrotate did not generate the rotated log file.

My config
AlmaLinux 9.6
CWP 0.9.8.1216

Contents of File: /etc/logrotate.d/sample.com.log
/usr/local/apache/domlogs/sample.com.log
{
    missingok
    daily
    copytruncate
    rotate 7
    notifempty
}

However, this feature does not trigger automatically.
Manual triggering can generate new log files.

Why is this? How to automatically generate a new log file?

Offline
*****
Re: Logrotate did not generate the rotated log file
« Reply #1 on: September 20, 2025, 11:54:16 AM »
This is what I have for httpd logs, runs successfully on AlmaLinux 8 (as it did on CentOS 7 before):
Code: [Select]
/usr/local/apache/domlogs/*.log {
    missingok
    notifempty
    sharedscripts
    daily
    rotate 7
    postrotate
        /sbin/service httpd reload > /var/log/httpd-rotate.log 2>&1 || true
    endscript
    compress
}

Offline
*
Re: Logrotate did not generate the rotated log file
« Reply #2 on: September 21, 2025, 12:09:30 AM »
I checked the logrotate logs and found the following error:
error: error opening /usr/local/apache/domlogs/sample.com.log: Read-only file system

Then I checked the permissions and owner of this file. Its permissions are 644, and the owner is root. Both permissions and owner seem correct. Why is it still read-only?
« Last Edit: September 21, 2025, 12:11:07 AM by gailclark80 »

Offline
****
Re: Logrotate did not generate the rotated log file
« Reply #3 on: September 21, 2025, 09:39:15 PM »
What is the result of lsattr on the file?
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: Logrotate did not generate the rotated log file
« Reply #4 on: September 22, 2025, 12:02:19 AM »
This is the result of the command.

Command:lsattr /usr/local/apache/domlogs/sample.com.log

Result: --------------e------- /usr/local/apache/domlogs/sample.com.log

Offline
****
Re: Logrotate did not generate the rotated log file
« Reply #5 on: September 22, 2025, 02:05:34 AM »
Is selinux enabled or disabled on your server?  If it's enabled, it's probably your problem.
Google Hangouts:  rcschaff82@gmail.com