0

I have a vps server but the vps provider stop managed service. I having problem with logs file. Every thing seems was alright, but after few month auto logs deletion does not working. Every minute the logs file grows by 10 mb all my vps space goes full due to this issue. i check the logrotaion file in etc folder.

The logrotation file configurations as follow:

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
    /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
    daily
    copytruncate
}

i want to delete the logs immediately. so please help someone

user9517
  • 115,471
  • 20
  • 215
  • 297
  • If your log grows with 10MB per minute you either have a very busy website or you're having a very serious problem. What do the logs actually say? – Oldskool Jul 03 '14 at 15:58

1 Answers1

2

The rotate directive specifies the number of prior log versions to keep before deleting them.

For CentOS the default value is usually specified in the main /etc/logrotate.conf file as

rotate 4

So it will keep 4 versions (usually 4 weeks worth). From the man page

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.

You can override the default value on a per log basis, again, from the man pages

logrotate reads everything about the log files it should be handling from the series of configuration files specified on the command line. Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones) and specify logfiles to rotate.

The documentation for the include directive contains further information on how config files are processed.

All you really need to do is add rotate 0 to the httpd log definition

/var/log/httpd/*log {
    rotate 0
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
   endscript
}

You probably don't want copytruncate in your definition either the postrotate scripot will take care of opening/closing the files.

user9517
  • 115,471
  • 20
  • 215
  • 297