cancel
Showing results for 
Search instead for 
Did you mean: 

house keeping script

 
Johnson Punniyalingam
Honored Contributor

house keeping script

Hi All,

Greetings & Good day,

I would like to write to script find files which are has been created past 60 mins and move those files to /var/adm/crash/ora

source folder :- /oracle/orarchieve
target folder :- /var/adm/crash/ora

thanks in advance for you kind advice & help

Regards,
Johnson
Problems are common to all, but attitude makes the difference
2 REPLIES 2
Steven E. Protter
Exalted Contributor

Re: house keeping script

Shalom Johnson,

Very interesting.

Here is a trick.

Example

touch -t 200509090900 /tmp/pivotfile

and use find's newer option:

find . type f -newer /tmp/pivotfile

# add -exec mv

Change the names to what you need.

Test thoroughly.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: house keeping script

Hi Johnson:

This should meet your needs:

# cat ./mover
#!/usr/bin/perl
use strict;
use warnings;
use File::Copy;
my $srcdir = qq(/oracle/orarchive);
my $dstdir = qq(/var/adm/crash/ora);
my @files = grep( -f && -M $_ > 3600 / 86400, glob("$srcdir/*") );
for my $file (@files) {
print "Moving $file -> $dstdir\n";
move( $file, $dstdir );
}
1;


...The value of 3600 represents 60-minutes. The value of 86400 is the number of seconds in a day.

Regards!

...JRF...