Logrotate configuration problem


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Logrotate configuration problem
# 1  
Old 12-11-2009
Logrotate configuration problem

Hi,

I have the following configuration file:

Code:
/logs/system/mindundi/* {
        rotate 0
        daily
        missingok
        sharedscripts
        postrotate
        find /logs/system/mindundi/ -name "*log" -mtime +15 -exec /bin/rm -f {} \;
        endscript
}

I want to save only the last 15 days old, but this configuration deletes all.

NOTE: All the files in the mindundi directory have a different name (f.e. abc123-20091211.log, abc178-20091210.log)

For more info config of logrotate.conf:

Code:
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

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

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

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

Can anybody help me?

Thanks,

Mitch.
# 2  
Old 12-11-2009
Code:
/logs/system/mindundi/* {
        rotate 0
        daily
        missingok
        sharedscripts
        postrotate
        find /logs/system/mindundi/ -name "*log" -mtime +15 -exec /bin/rm -f {} \;
        endscript
}


rotate 0 is the culprit which removes everything i believe.
# 3  
Old 12-11-2009
I have the same problem. If the problem is rotate, how can I fix it?
# 4  
Old 12-11-2009
The problem is you're using logrotate for something it wasn't designed for.

It was written to move/compress/truncate/... logs at a certain size or after a certain time since it was first seen/last rotated, and to make sure those rotated are still available. It's been designed to manage ever-growing logs like Apaches access_log/error_log or syslog. It's not been designed to remove singular logs.

If you just want to delete files after they've not been modified for a certain time, create a cronjob for that:
Code:
0 2 * * * find /logs/system/mindundi/ -name "*log" -mtime +15 -exec /bin/rm -f {} \;

# 5  
Old 12-11-2009
Quote:
Originally Posted by OrBiS
I have the same problem. If the problem is rotate, how can I fix it?

To fix it, you need increase the rotate 0 to to some other number, to save last 5 days file, then use:

Code:
rotate 5

# 6  
Old 12-18-2009
i found solution ^^

logrotate.sh
Code:
#!/bin/ksh

mkdir -p /tmp/logrotate
touch -t 0101010101 /tmp/logrotate/dummy
/usr/sbin/logrotate /etc/logrotate.conf

And config file:
Code:
/tmp/logrotate/dummy {
firstaction
        find /logs/xxx/*/xxx* -name "*.log" -mtime +7 -exec /bin/rm -f {} \;
        find /logs/yyy/*/www* -name "www*.log" -mtime +7 -exec /bin/rm -f {} \;
        find /logs/zzz/*/qqq* -name "*.log*" -mtime +7 -exec /bin/rm -f {} \;
endscript
rotate 1
daily
missingok
}

is similar to your proposal, but so is centralized around with logrotate
# 7  
Old 12-29-2009
It works ^^
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

When to use sharedscripts in a Logrotate Configuration?

Hello All, OS: SLES 11.3 x86_64 Should I be using the sharedscripts config command for my logrotate configuration, given the info below? I made it so the server sending the log data will do Syslog pushes of 3 types of logs to my SLES server, and all 3 logs will be written into the same... (3 Replies)
Discussion started by: mrm5102
3 Replies

2. Shell Programming and Scripting

Problem with logrotate

Hi, I have a problem with logrotate at Centos 7. My logrotate is configured with "rotate 0" to Apache logs, so it should never keep logs when rotating, just removing them and replacing by new empty ones at every rotation. But for some reason, once in a while, I see that logrotate is creating... (0 Replies)
Discussion started by: dado000
0 Replies

3. UNIX for Dummies Questions & Answers

Logrotate configuration

Hi all, i would like to have a configuration on log rotate that will gzip my log files with date pattern %Y-%m-%d move these files to an olddir, but i want to avoid that the logrotate removes my files from old dir newer than 180 days i applyied this config #logrotate config to compress files... (3 Replies)
Discussion started by: charli1
3 Replies

4. AIX

Logrotate - /etc/logrotate.conf does't exist

Hi Admins. I have installed logrotate rpm on Aix 6.1. After the installation of rpm, I don't find /etc/logrotate.conf file and /etc/logrotate.d dir . The config file is located in /opt/freeware/etc/logrotate.conf. When I ran logrotate -v /opt/freeware/etc/logrotate.conf I get below... (2 Replies)
Discussion started by: snchaudhari2
2 Replies

5. Shell Programming and Scripting

Logrotate - I am not able to rotate files using logrotate

I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest. I am using below command... (5 Replies)
Discussion started by: VSom007
5 Replies

6. UNIX for Advanced & Expert Users

rotate modsec log with logrotate in the global configuration

Hello Experts, I have an apache 2.2.17 on solaris 10 that I am not sure if I, could list the following in the global settings in httpd.conf. I tested it in the Virtual host section of httpd.conf and, it works but, not sure if I can do it in the global settings. Any help would be greatly... (0 Replies)
Discussion started by: afadaghi
0 Replies

7. UNIX for Advanced & Expert Users

logrotate with /etc/logrotate.conf file

Hi there, I want to rotate the logfiles which are located in /var/log/jboss/tomcat* so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content. # cat /etc/logrotate.d/tomcat /var/log/jboss/tomcat_access_log*.log { daily nocreate ... (2 Replies)
Discussion started by: skmdu
2 Replies

8. Solaris

Problem in network configuration

Hi everybody, I have a very strange problem ; if somebody could help me it would be very kind. I'll try to explain my problem. I have 2 unix machines absolutely identical running solaris 9. For network reasons I need to change the IP address of the 2 machines. I proceed exactly the same on the... (11 Replies)
Discussion started by: aribault
11 Replies

9. Red Hat

Problem seen with logrotate

Hi all, I have configured logrotate to logorotate every 12 hour. The configurations are as follows. /etc/cron.d/config ------------------------- SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="" HOME=/root 0 */12 * * * root logrotate /etc/logrotate.d/test ... (1 Reply)
Discussion started by: rsravi74
1 Replies

10. UNIX for Advanced & Expert Users

cron/logrotate chicken and egg problem

I have run into a problem where about a dozen machines, all the same x86_64 2.6.12 GNU/Linux. For some reason these machines will fill up their /var partition (10G), because their logs never get rotated... Unfortunately, there is no error message from logrotate (would be in /var/log/messages) and... (8 Replies)
Discussion started by: jjinno
8 Replies
Login or Register to Ask a Question