Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Deleting files from O/S older than 6 hours

Re: Deleting files from O/S older than 6 hours

From: Jared Still <jkstill_at_gmail.com>
Date: Wed, 28 Nov 2007 16:25:18 -0800
Message-ID: <bf46380711281625i49e12eb9pf45a73246a26555e@mail.gmail.com>


On Nov 28, 2007 2:37 PM, Ajay Thotangare <ajayoraclel_at_yahoo.com> wrote:
> HP does not support mmin.
> Thanks for good tip with respect to "-exec"
>

Surely you have Perl available? :)

The script at the end of this email will find all files in the current directory that are older than 6 hours.

It is a slightly modified version of what find2perl generates. (find2perl does not support -mmin, but the generated script can be hacked)

-- 
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist


#! /usr/local/bin/perl -w
use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;

my $currentTime=time;

# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, 'find', '.');
exit;


sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime);
    my $seconds=6*60*60; # 6 hours

    (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime) =
lstat($_)) &&
         (($currentTime-$mtime) > $seconds)
    && print("$name\n");

}
--
http://www.freelists.org/webpage/oracle-l
Received on Wed Nov 28 2007 - 18:25:18 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US