[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Small improvement to find's mtime to support for seconds
From: |
Prashant Sharma |
Subject: |
Re: Small improvement to find's mtime to support for seconds |
Date: |
Wed, 30 Jan 2013 12:40:45 +0530 |
On Wed, Jan 30, 2013 at 3:15 AM, James Youngman <address@hidden> wrote:
> On Tue, Jan 29, 2013 at 8:32 AM, Prashant Sharma <address@hidden>
> wrote:
> > Apologies for not using a proper subject. So changed it!.
> >
> > On Tue, Jan 29, 2013 at 1:54 PM, Prashant Sharma <address@hidden
> >wrote:
> >
> >> The need for this arose with following scenario.
> >> I have stream processing engine doing some random stuff and creating a
> lot
> >> of files in the process. And since I did not wrote it myself and people
> who
> >> wrote it do not have clearing up mechanism for the files that accumulate
> >> and tend to either fill Inodes or File-system.
> >>
> >> So needed a way for clearing things up older than 30 seconds.
>
> Just use -newermt:
>
> find /tmp -newermt "$(date '+%Y%m%d%H%M%S' -d '30 seconds ago')"
>
> (I didn't test this so the format argument to the date command may be
> wrong, the only Linux box I have easy access to now is running
> findutils 4.4.2 which is too old to have -newermt).
>
Thanks James for that suggestion. I am still trying to make it work. BTW I
have findutils 4.4.2 too, it seems to have newermt.
find /tmp -type f ! -newermt "30 seconds ago"
seems to work.
--
s