logrotate.d (rotating directories?)
I've tried to find some good reference documentation on
logrotate.conf files, but couldn't find anything solid. The
links that I've found are attached below [1].
Basically, I have some processes that dump data to
/var/log/something/YYYY-MM-dd/* ... these are all reasonably
complicated sub-trees within each day's folder, but basically,
I'm trying to use logrotate to rotate / delete the folders in
bulk, and I don't even know that it's possible (and
documentation isn't 100%, from what I could tell).
1) I'm worried about disk space, otherwise I'd just let these
directories grow without bound. :^)
2) Recent log directories need to have files accessible
(nocompress)?
3) I'm cool with having a 1-2 week turnaround on these files,
here was my first attempt:
rames@gimpus:~$ cat ~/test.conf
/var/log/something/* {
rotate 14
daily
}
...logrotate -d test.conf gives:
rames@gimpus:~$ /usr/sbin/logrotate -d test.conf
reading config file test.conf
reading config info for /var/log/something/*
Handling 1 logs
rotating pattern: /var/log/something/* after 1 days (14
rotations)
empty log files are rotated old logs are removed
...but I'm confused because it says: "Handling 1 logs" and I
think that won't quite work (probably need to involve the
prerotate thing).
As much as I hate to re-invent the wheel, I was thinking of ways
to roll our own little script b/c like I said, I don't have a
great understanding of how logrotate would handle this
(directories of logs containing subdirectories). Possibly
somebody just needs to whack me with the tar manpage (and how
tar interacts with logrotate).
Here is an alternative that I came up with (pseudocode bash b/c
I don't want to debug it until I know that logrotate won't
work):
cron: @hourly
#!/bin/sh
# find free space in kb
FREESPACE=`df | grep hda2 | awk '{print $4}'`
# see if it is "too little"
if [ `expr $FREESPACE \< 1000000` ]
# yes, too little, find oldest named directory to delete
TO_DELETE=`ls -r /var/log/something | tail -1`
if [ "$TO_DELETE" ne "" ]
# don't ever delete a blank
# (would delete *everything*)
rm -rf -- "/var/log/something/$TO_DELETE"
echo "Deleted: $TO_DELETE to save space" | mail
-s "Clearing old logs..." me@my.com
fi
fi
...I'm grasping at straws here, some sage advice would be very
welcome. (and a CC would be welcome, too, as I read debian-user
through the web archives, and the DWN :^)
--Robert
[1] URL's...
Man page:
http://www.oreillynet.com/linux/cmd/l/logrotate.html
Neat/useful:
http://lena.franken.de/linux/sysadmin.html#logrotate
Generic info:
http://www.linuxhomenetworking.com/linux-hn/logging.htm#_Toc36811063
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
Reply to: