Need help with logrotation

 
Thread Tools Search this Thread
Operating Systems Linux Fedora Need help with logrotation
# 1  
Old 11-18-2009
Java Need help with logrotation

Hi

I need help in rotating logs.
A folder /tftpboot holds following directories, these directories are created everyday automatically, these are backup folders, that is they hold backup of data.
drwxr-xr-x 2 phone phone 4096 Nov 1 13:19 1nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 2 13:19 2nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 3 13:19 3nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 4 13:19 4nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 5 13:19 5nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 6 13:19 6nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 7 13:19 6nov09.bkp
drwxr-xr-x 2 phone phone 4096 Nov 8 13:19 6nov09.bkp

I need to set up an entry in logrotate to delete these backup directories in /tftpboot directory that are greater than 1 week old.
Can someone help me how to do the same?
# 2  
Old 11-18-2009
Try with this logrotate configuration...

Code:
/tftpboot/*.bkp {
        daily
        nocreate
        rotate 1
        compress
        missingok
        postrotate
                find /tftpboot/ -iname 'bkp*.gz' -type f -mtime +7 -exec rm -f \{\} \;
        endscript
}

Code:
Explanation : 
1. This configuration is for /tftpboot/*.bkp files
2. Daily it will watch
3. nocreate- it wont create if the (todays) current date file doesn't exist.
4. rotate 1 - it needs to compressed and rotated only once (because all the files will be with unique name).
5. compress - enable default compress gzip
6. missingok - if the file is missing it should not stop with error
7. After rotation it executes the find command which removes 1 week old files

# 3  
Old 11-18-2009
Bug

Hi

thanks for the reply and solution... I want to ask you a question that *.bkp are directories and not files under /tftpboot directory. I am not sure if we can rotate directories using logrotate.

find /tftpboot/ -iname 'bkp*.gz' -type f -mtime +7 -exec rm -f \{\} \;

Also would you please explain what [ -exec rm -f \{\} \; ] means..
# 4  
Old 11-18-2009
which OS do you use? solaris for example has a nice tool called "logadm".
# 5  
Old 11-18-2009
I am using fedora core 6. Can we delete directories using logrotate?
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Solaris

Problem with logrotation

Hi, I have been trying to configure log rotation for the OS version Solaris 10, however it is not working. In Linux, these would be the parameters : rotate 4 missingok notifempty compress size 15M create 0644 root root To do the same in Solaris, I am not sure of the exact parameters... (3 Replies)
Discussion started by: anaigini45
3 Replies

2. Shell Programming and Scripting

Logrotation

Hi , We have so many log files which will increase the size day by day.. can any one let us know how to rotate the log files.. I want to move the logfile to other location after particular time and size of the log file is there any script to change these?? (2 Replies)
Discussion started by: phani4u
2 Replies
Login or Register to Ask a Question