Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

delelte dirs older than 2 hours by find with solaris 9

680 views
Skip to first unread message

Frank Schmitz

unread,
Nov 27, 2006, 2:45:21 AM11/27/06
to
Hi!

I run Solaris 9 and want to delete some directories older than 2
hours. Like this:

find /MYDIR/ -name "MYPATTERN" -type d -mmin +120 -exec rm -R {} \;

But there ist no option like "mmin" in Solaris 9, I can only select
files older than whole days by "-mtime", but not by hours.

Is there someting like "gnu-find" I can use oder another way to
select files accessed some hours ago?

Thanks!

JNR

unread,
Nov 27, 2006, 4:26:18 AM11/27/06
to
You need to compile and install gnu find.

http://www.gnu.org/software/findutils/

JNR

unread,
Nov 27, 2006, 4:26:54 AM11/27/06
to
You need to compile and install gnu find.

http://www.gnu.org/software/findutils/

--
- JNR.

James Carlson

unread,
Nov 27, 2006, 6:57:23 AM11/27/06
to
"JNR" <mjana...@gmail.com> writes:
> You need to compile and install gnu find.
>
> http://www.gnu.org/software/findutils/

You shouldn't need to do that. You can get GNU find for S9 already
compiled and in package format from any of several sources. It's on
the companion CD as SFWgfind. It's in blastwave.org as findutils.
It's on sunfreeware.com as findutils-4.2.27.

If you're using Solaris and you haven't looked into the free sources
of precompiled software for it, you may want to do that. There's a
lot available.

--
James Carlson, KISS Network <james.d...@sun.com>
Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677

Casper H.S. Dik

unread,
Nov 27, 2006, 8:35:34 AM11/27/06
to
James Carlson <james.d...@sun.com> writes:

>"JNR" <mjana...@gmail.com> writes:
>> You need to compile and install gnu find.
>>
>> http://www.gnu.org/software/findutils/

>You shouldn't need to do that. You can get GNU find for S9 already
>compiled and in package format from any of several sources. It's on
>the companion CD as SFWgfind. It's in blastwave.org as findutils.
>It's on sunfreeware.com as findutils-4.2.27.

>If you're using Solaris and you haven't looked into the free sources
>of precompiled software for it, you may want to do that. There's a
>lot available.


Or he can use a more recent version of Solaris which does have
the -cmin/amin/mmin options.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

Tim Hogard

unread,
Nov 27, 2006, 10:29:51 AM11/27/06
to
Frank Schmitz (AXHLTV...@spammotel.com) wrote:
: Hi!

Some finds (from pres SYS V days) are happy with floating point
values for times that reduce to integers in seconds....
find .... -atime +.083333

-tim
http://web.abnormal.com

Darren Dunham

unread,
Nov 27, 2006, 3:46:45 PM11/27/06
to
Frank Schmitz <AXHLTV...@spammotel.com> wrote:
> Hi!

> I run Solaris 9 and want to delete some directories older than 2
> hours. Like this:

> find /MYDIR/ -name "MYPATTERN" -type d -mmin +120 -exec rm -R {} \;

> But there ist no option like "mmin" in Solaris 9, I can only select
> files older than whole days by "-mtime", but not by hours.

Even if you don't have access to a 'find' that accepts minutes, you can
use 'touch' to create a file of the correct age. Then use find -newer
(or ! -newer) to select files newer or older than that point in time.

--
Darren Dunham ddu...@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >

Oscar del Rio

unread,
Nov 27, 2006, 3:47:37 PM11/27/06
to
Frank Schmitz wrote:
> I run Solaris 9 and want to delete some directories older than 2
> hours.

Create a timestamp file that is 2 hours old, using TZ tricks, like

touch -t `TZ=GMT+3 date '+%y%m%d%H%M'` .TIMESTAMP
find /dir -type d \! -newer .TIMESTAMP .....

The environ(5) man page has details about the TZ format.
You might have to compensate for std vs dst timezones.

Tim Bradshaw

unread,
Nov 27, 2006, 3:58:13 PM11/27/06
to
On 2006-11-27 20:46:45 +0000, Darren Dunham <ddu...@redwood.taos.com> said:

> Even if you don't have access to a 'find' that accepts minutes, you can
> use 'touch' to create a file of the correct age. Then use find -newer
> (or ! -newer) to select files newer or older than that point in time.

Now that is a really neat trick. Do you know (could be easily checked
obviously but I'm not near a Solaris box that is on) if it is smart
enough not to stat the file repeatedly?

--tim


Darren Dunham

unread,
Nov 27, 2006, 5:48:26 PM11/27/06
to

Could look at the code, but no I think it just stats the file once to
get a time (rather like the -mtime and others generate a time) and that
is checked against the files. I only see one stat on a test.

Frank Schmitz

unread,
Nov 28, 2006, 2:41:43 AM11/28/06
to

>If you're using Solaris and you haven't looked into the free sources
>of precompiled software for it, you may want to do that. There's a
>lot available.

I have installed that package.

I wasn´t quite shure if there was a "find"-package, thanks for the
advice!

0 new messages