Monday, February 18, 2013

Find files which are older than 15 minutes in Linux and Solaris..


The below example is for moving (mv) files, same can be changes easily for rm, ls, cp etc. One has to make change in xargs paramaeter.

In LINUX:
=========

find /path_to_directory/ -name "*.rpt" -type f -mmin +15 | xargs -I {} mv {} /target_directory_path/


In Solaris:
===========

#! /usr/bin/sh

#### Create a reference file minute_test
touch /path_to_directory/minute_test

#### Make minute_test 15 minutes old
sleep 900

#### Move all .rpt files to some other directory which are older than reference file minute_test
find /path_to_directory/ -name "*.rpt" -type f -newer minute_test | xargs -I {} mv {} /target_directory_path/

#### Remove reference file
rm -f /path_to_directory/minute_test


3 comments:

Unknown said...

It was very nice article and it is very useful to Linux learners.We also provide Linux online training

J said...

Hi

This is really informative site. You can find more <a href="http://techgoeasy.com/unix-command-and-scripts/>Unix tutorial</a> here

Thanks

Anonymous said...

Great content.Check Unix tutorial for more content

 

Blogger news

Blogroll