Logrotate Removing Logs

Issues related to applications and software problems
dcrdev
Posts: 64
Joined: 2015/10/25 23:42:17

Logrotate Removing Logs

Postby dcrdev » 2018/01/12 19:08:35

I'm trying to set up a custom logrotate config for some Apache virtualhost logs, but logrotate is creating the new empty log files and the old ones ares nowhere to be found. I ran find on the entire filesystem and they simply don't exist - can anyone help:

Code: Select all

cat /etc/logrotate.d/custom_httpd
/storage/WWW/*/*log {
    su root group
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
   /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}


Code: Select all

logrotate -df /etc/logrotate.d/custom_httpd
[root@hostname logrotate.d]# logrotate -fd /etc/logrotate.d/custom_httpd
reading config file /etc/logrotate.d/custom_httpd
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /storage/WWW/cloud.domain.com/log/*log  forced from command line (no old logs will be kept)
empty log files are not rotated, old logs are removed
considering log /storage/WWW/cloud.domain.com/log/access_log
  log needs rotating
considering log /storage/WWW/cloud.domain.com/log/error_log
  log does not need rotating (log is empty)considering log /storage/WWW/cloud.domain.com/log/ssl_access_log
  log needs rotating
considering log /storage/WWW/cloud.domain.com/log/ssl_error_log
  log does not need rotating (log is empty)considering log /storage/WWW/cloud.domain.com/log/ssl_request_log
  log needs rotating
rotating log /storage/WWW/cloud.domain.com/log/access_log, log->rotateCount is 0
dateext suffix '-20180112'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /storage/WWW/cloud.domain.com/log/access_log.1 to /storage/WWW/cloud.domain.com/log/access_log.2 (rotatecount 1, logstart 1, i 1),
renaming /storage/WWW/cloud.domain.com/log/access_log.0 to /storage/WWW/cloud.domain.com/log/access_log.1 (rotatecount 1, logstart 1, i 0),
rotating log /storage/WWW/cloud.domain.com/log/ssl_access_log, log->rotateCount is 0
dateext suffix '-20180112'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /storage/WWW/cloud.domain.com/log/ssl_access_log.1 to /storage/WWW/cloud.domain.com/log/ssl_access_log.2 (rotatecount 1, logstart 1, i 1),
renaming /storage/WWW/cloud.domain.com/log/ssl_access_log.0 to /storage/WWW/cloud.domain.com/log/ssl_access_log.1 (rotatecount 1, logstart 1, i 0),
rotating log /storage/WWW/cloud.domain.com/log/ssl_request_log, log->rotateCount is 0
dateext suffix '-20180112'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /storage/WWW/cloud.domain.com/log/ssl_request_log.1 to /storage/WWW/cloud.domain.com/log/ssl_request_log.2 (rotatecount 1, logstart 1, i 1),
renaming /storage/WWW/cloud.domain.com/log/ssl_request_log.0 to /storage/WWW/cloud.domain.com/log/ssl_request_log.1 (rotatecount 1, logstart 1, i 0),
fscreate context set to system_u:object_r:public_content_rw_t:s0
renaming /storage/WWW/cloud.domain.com/log/access_log to /storage/WWW/cloud.domain.com/log/access_log.1
disposeName will be /storage/WWW/cloud.domain.com/log/access_log.1
fscreate context set to system_u:object_r:public_content_rw_t:s0
renaming /storage/WWW/cloud.domain.com/log/ssl_access_log to /storage/WWW/cloud.domain.com/log/ssl_access_log.1
disposeName will be /storage/WWW/cloud.domain.com/log/ssl_access_log.1
fscreate context set to system_u:object_r:public_content_rw_t:s0
renaming /storage/WWW/cloud.domain.com/log/ssl_request_log to /storage/WWW/cloud.domain.com/log/ssl_request_log.1
disposeName will be /storage/WWW/cloud.domain.com/log/ssl_request_log.1
running postrotate script
running script with arg /storage/WWW/cloud.domain.com/log/*log : "
   /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
"
removing old log /storage/WWW/cloud.domain.com/log/access_log.1
error: error opening /storage/WWW/cloud.domain.com/log/access_log.1: No such file or directory


Thought it might be selinux - so I temporarily put it into permissive mode, it did not help.

User avatar
avij
Forum Moderator
Posts: 2231
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Logrotate Removing Logs

Postby avij » 2018/01/12 19:50:49

man logrotate wrote:rotate count
Log files are rotated count times before being removed or mailed to the address specified in a mail directive. If count is 0, old versions are removed rather than rotated.

Try adding rotate 99 somewhere.

dcrdev
Posts: 64
Joined: 2015/10/25 23:42:17

Re: Logrotate Removing Logs

Postby dcrdev » 2018/01/13 00:04:13

Thanks that pointed me in the right direction -

So when logrotate is called via cron it passes /etc/logrotate.conf as the config, that file has an include on /etc/logrotate.d/* . The main config file /etc/logrotate.conf has the logrotate directive set to 4, when passing the configs from /etc/logrotate.d directly this directive does not get set.

So in actual fact the config above was fine all along, just needs to be called differently.