[nylug-talk] logrotate question
C Thala
cthala at gmail.com
Sat Feb 2 17:09:14 EST 2008
On Feb 2, 2008 5:07 PM, C Thala <cthala at gmail.com> wrote:
> On Feb 2, 2008 5:00 PM, Kristian Erik Hermansen wrote:
> > > I would like to keep the last N files. Let's say 5.
> >
> > Delete all files created more than 5 days ago?
> > $ find /path/to/logs -ctime +5 -type f -exec rm -f {} \;
>
> I know how to use find/xargs to delete files by timestamp.
>
> What I want to do is to delete anything over the last N files.
I should add that the reason I don't want to do this by date is that
the file creation process may stall for whatever reason. If we delete
anything over X hours/days, we run into the issue where it will delete
everything. I want the last N files to *always* be there.
More information about the nylug-talk
mailing list