[nylug-talk] logrotate question

Kristian Erik Hermansen kristian.hermansen at gmail.com
Sat Feb 2 18:28:17 EST 2008


On Feb 2, 2008 2:49 PM, N.J. Thomas <njt at ayvali.org> wrote:
> I suppose I should have put a sort in there, like this:
>
>     ls foo.*gz|sort|head -n -5|xargs rm -f
>
> because I'm never quite sure if ls/find sorts output properly or not.
>
> But why do you say that this solution is wrong?

It actually works.  The only problem is that you can't always expect
ls to produce sorted output and file names with spaces, if ever
created, will not properly be removed.  Granted, given her current
input, this is not a problem.  But usually people who need this kind
of assistance get stumped when they start using new input and wonder
why everything is broken, only becaus the new file names have spaces
in them :-(  Just my two cents.  For something as important as log
files, I wouldn't want to take a chance of blowing away the wrong
ones, or even worse, having an attacker craft some input that make you
accidentally delete some important data!  You never know what can
happen!!!  Cheers!  It was an elegant hack over hers and mine though
[i thought the files run via cron perhaps and always have correct
timestamp] :-)
-- 
Kristian Erik Hermansen
"Know something about everything and everything about something."


More information about the nylug-talk mailing list