EzDevInfo.com

logrotate interview questions

Top logrotate frequently asked interview questions

ProFTPD killed (signal 15) error - how to fix logrotate restart error? [closed]

ProFTPD on Ubuntu is being killed unexpectedly.

Log message:

$ tail /var/log/proftpd/proftpd.log.1
...
... ProFTPD killed (signal 15)
... ProFTPD 1.3.5rc3 standalone mode SHUTDOWN

Diagnosis: the time of the message is the same time that cron runs the logrotate command.

Google searches turn up various info about ProFTPD having a glitch on Debian-based systems due to log files, log rotations, and the ProFTPD server not restarting.

I will add a bounty for a solution to this. I've posted a workaround answer too, in case it's helpful for others.


Source: (StackOverflow)

Redis logrotate config

Does anyone have a sample logrotate config for redis? This is what I have so far

/var/log/redis/*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                ...
        endscript
}

But I'm not sure what to do on the postrotate step. This is on Ubuntu 10.04 LTS.


Source: (StackOverflow)

Advertisements

Linux-Java logs rotating using log4j or logrotate.d

I have a Spring project using log4j on Linux (Debian, Ubuntu and RHEL). Now I would like to implement best practice logs rotation for the log4j generated logs.

I have previously used logrotate.d for other non-java components and it worked great for me. I needed rotating by size/time and compressing the old logs and logrotate could do all of this.

I am new to log4j and now wonder how should I configure log rotation.

  1. Should I use log4j only for logging and logrotate for rotation?
  2. Use only log4j for rotation?
  3. Use a mix of both?

What is your experience? What is the best practice?


Source: (StackOverflow)

log4j fileappender doesn't switch to the new file when logrotate rotates the log file

Context:

I want to use log4j to write audit-related logs to a specific log file, let's say audit.log. I don't want to use syslogappender(udp based) because I don't want to be tolerant to data loss. Plus, I am using logrotate to rotate the audit.log when the file gets to certain size.

Problem:

I am encountering is that, when logrotate rotates the file audit.log to audit.log.1, log4j keeps writing to audit.log.1 other than writing to the audit.log.

Possible approaches:

  1. I know I can use rollingfileappender to do the log rotation other than use logrotate, so when rollingfileappender rolls the file, it switch to the new file without hassles. But the reason I can't use rollingfileappender is that I want to use logrotate's post rotate feature to trigger some scripts after the rotation happens which can't be provided by rollingfileappender.

  2. Another desperate way I can think of is to write a log4j customized appender myself to close the log file(audit.log.1) and open the new one(audit.log) when it detects the file is rotated.

  3. I never used ExternallyRolledFileAppender, but if it's possible to use logrotate post rotate to send the signal to ExternallyRolledFileAppender and make log4j aware the file is rotated, and start writing to the new file?

Question:

Just wondering is there some appender like that already been invented/written? or do I have other options to solve this?


Source: (StackOverflow)

How do I create a logrotate friendly file writer in Java or other platform?

What are the best practices for implementing a file writer/logger in Java that is compatible with logrotate? The goal would be allow logrotate to be used for all log management, instead of using built-in rotation/management of a logging API (Log4J, etc).

I'd be interested in hearing comments/answers for other development platforms, aside from Java.


Source: (StackOverflow)

logrotate configuration file development and testing

I have two questions related to developing configuration files for the logrotate tool on Linux systems.

  1. When I make a change to a file in /etc/logrotate.d, do I need to somehow notify logrotate so that it will recognize and respond to the change? It seems to notice changes on its own, eventually, but when testing log rotation specifications it would be useful to force logrotate to react to a new configuration file, rather than waiting for it to next run. Is this possible?

  2. If there is a problem in my logrotate configuration file, are errors reported and if so where can I find them?

Also, if there are common development patterns and techniques to follow when developing logrotate configuration files, please share them. If it matters, I am using Ubuntu 10.04.


Source: (StackOverflow)

Logrotate files with date in the file name

I am trying to configure logrotate in RHEL for tomcat6 logs. Currently, logrotate works fine for catalina.out log, it is rotated and compressed properly.

The problem is with the files with date in them like:

catalina.2012-01-20.log
catalina.2012-01-21.log
catalina.2012-01-22.log

These files are not being rotated. I understand that I have to configure these in /etc/logrotate.d/tomcat6 file where rotation for catalina.out is configured. But I am not able to configure it.

All I want is these older files to be compressed daily, except the current date log file.

Can anybody help me out on this, please!!

Thanks Noman A.


Source: (StackOverflow)

Centos/Linux setting logrotate to maximum file size for all logs

we use logrotate and it runs daily ... now we have had some situations where logs have grown significantly (read: gigbaytes) and killing our server. So now we would like to set a maximum filesize to the logs ....

can I just add this to the logrotate.conf?

size 50M

and would it then apply to all log files? Or do I need to set this on a per log basis?

Or any other advice?

(ps. I understand that if you want to be notified is the log grows like described and what we want to do is not ideal - but it is better than not being able to logon anymore because there is no space available)

thanks, Sean


Source: (StackOverflow)

Hourly rotation of files using logrotate? [closed]

I tried to set up a log rotation of logs files located at /tmp/hr_logs/. For setting up, I used logrotate in linux and I'm able to rotate it on daily basis using the following config in my /etc/logrotate.conf

  /tmp/hr_logs {
  daily
  rotate 4

With this config, file will rotate on daily basis and system will keep 4 copies of the log file appended with date [format: -YYYYMMDD]

Now, I trying to set up a different set of log files which I need to make rotate on hourly basis and for it, i have done the configuration in logrotate.conf:

  /tmp/last_logs {
  hourly
  rotate 4

But this is not at all working? Can anyone please guide me on this please?


Source: (StackOverflow)

error: error creating state file /var/lib/logrotate/status: Permission denied

Trying to use logrotate and I get the following error when I run the log rotate script for a particular definition in logrotate.d

error: error creating state file /var/lib/logrotate/status: Permission denied

/var/lib/logrotate$ ls -lah
total 12K
drwxr-xr-x  2 root root 4.0K 2012-05-11 06:25 .
drwxr-xr-x 43 root root 4.0K 2012-05-18 08:07 ..
-rw-r--r--  1 root root  911 2012-05-25 06:25 status

I haven't touched that path, so I wonder why it would create an error by default...


Source: (StackOverflow)

Apache rotate Access and Error logs Windows

How can I rotate the Apache Access and Error logs on a Window 2000 box?

I include my batch file below as an answer.

Is there a way of doing this directly via the Apache config file? I'm currently using the following customlog command to generate daily logs.

CustomLog '|" "Apache-Path/bin/rotatelogs.exe" "Apache-Path/logs/backup/internet_access_%d-%m-%y.log" 86400' combined


Source: (StackOverflow)

How can I fix "/etc/cron.daily/logrotate: gzip: stdin: file size changed while zipping"?

in last days i get daily mail from cron's logrotate task:

/etc/cron.daily/logrotate:

gzip: stdin: file size changed while zipping

How can I fix it?

Thanks, Gian Marco.


Source: (StackOverflow)

How to insert a date inside the filename with logrotate

I need to set logrotate to rotate logs files from an application running on the server. I need the date inside the filename.

I set dateext and also dateformat to add a - in the date. The result filename is:whatever.csv_2012-03-03

I would like the timestamp to be part of the filename keeping safe the extension; Whatever_2012-03-03.csv.


Source: (StackOverflow)

Is it possible to run one logrotate check manually?

Is it possible to run one iteration of logrotate manually without scheduling it on some interval?


Source: (StackOverflow)

How to configure logrotate with php logs

I'm running php5 FPM with APC as an opcode and application cache. As is usual, I am logging php errors into a file.

Since that is becoming quite large, I tried to configure logrotate. It works, but after rotation, php continues to log to the existing logfile, even when it is renamed. This results in scripts.log being a 0B file, and scripts.log.1 continuing to grow further.

I think (haven't tried) that running php5-fpm reload in postrotate could resolve this, but that would clear my APC cache each time.

Does anybody know how to get this working properly?


Source: (StackOverflow)