delelte dirs older than 2 hours by find with solaris 9

  • Follow


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!
0
Reply Frank 11/27/2006 7:45:21 AM

You need to compile and install gnu find.

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

Frank Schmitz 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.
>
> Is there  someting like "gnu-find" I can use oder another way to
> select files accessed some hours ago?
> 
> Thanks!

0
Reply JNR 11/27/2006 9:26:18 AM


You need to compile and install gnu find.

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

--
- JNR.

Frank Schmitz 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.
>
> Is there  someting like "gnu-find" I can use oder another way to
> select files accessed some hours ago?
> 
> Thanks!

0
Reply JNR 11/27/2006 9:26:54 AM

"JNR" <mjanardhan@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.carlson@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
0
Reply James 11/27/2006 11:57:23 AM

James Carlson <james.d.carlson@sun.com> writes:

>"JNR" <mjanardhan@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.
0
Reply Casper 11/27/2006 1:35:34 PM

Frank Schmitz (AXHLTVXKGKBF@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.
: 
: Is there  someting like "gnu-find" I can use oder another way to
: select files accessed some hours ago?

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
0
Reply thogard 11/27/2006 3:29:51 PM

Frank Schmitz <AXHLTVXKGKBF@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                                           ddunham@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. >
0
Reply Darren 11/27/2006 8:46:45 PM

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.
0
Reply Oscar 11/27/2006 8:47:37 PM

On 2006-11-27 20:46:45 +0000, Darren Dunham <ddunham@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


0
Reply Tim 11/27/2006 8:58:13 PM

Tim Bradshaw <tfb@tfeb.org> wrote:
> On 2006-11-27 20:46:45 +0000, Darren Dunham <ddunham@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?

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.

-- 
Darren Dunham                                           ddunham@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. >
0
Reply Darren 11/27/2006 10:48:26 PM

>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
Reply Frank 11/28/2006 7:41:43 AM

10 Replies
2895 Views

(page loaded in 0.12 seconds)

Similiar Articles:













7/19/2012 6:38:08 PM


Reply: