How to go about rotating logs which are arbitrary named and placed in deeply nested directories?
Posted
by
Roman Grazhdan
on Server Fault
See other posts from Server Fault
or by Roman Grazhdan
Published on 2014-06-02T20:53:02Z
Indexed on
2014/06/02
21:30 UTC
Read the original article
Hit count: 246
I have a couple of hosts which are basically a playground for developers. On these hosts, each of them has a directory under /tmp where he is free to do all he wants - store files, write logs etc.
Of course, the logs are to be rotated, or else the disc will be 100% full in a week. The files can be plenty, but I've dealt with it with paths like /tmp/[a-e]*/*
and so on and lived happily for a while, but as they try new cool stuff on the machine logrotate
rules grow ugly and unmanageable, and it's getting more difficult to understand which files hit the glob. Also, logrotate would segfault if asked to rotate a socket.
I don't feel like trying to enforce some naming policies in that environment, I think it's going to take quite a lot of time and get people annoyed and still would fail at some point.
And I still need to manage the logs, not just rm the dirs at night.
So is it a good idea in circumstances like these to write a script which would handle these temporary files? I prefer sticking with standard utilities whenever possible, but here I think logrotate is getting less and less manageable.
And probably someone heard of some logrotate alternatives which would work well in such an environment? I don't need emailing logs or some other advanced features, so theoretically some well commented find | xargs would do.
P.S. I do have a log aggregator but this stuff is not going to touch my little cute logstash machine.
© Server Fault or respective owner