Operating System - HP-UX
1837149 Members
2142 Online
110112 Solutions
New Discussion

Re: Find command - find files changed within the last 30 minutes

 
SOLVED
Go to solution
Kevin McNamara_1
Occasional Advisor

Find command - find files changed within the last 30 minutes

I have used the "find" commnad to identify files that have change in the last 24 hours. What command can I used to identify files that have been changed within minutes?
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Find command - find files changed within the last 30 minutes

Use the touch command to create a file with a given timestamp then use the -newer find option to find files newer than your reference file. Man touch and find for details.
If it ain't broke, I can fix that.
Geoff Wild
Honored Contributor

Re: Find command - find files changed within the last 30 minutes

Setup a cron job to touch a file every 30 minutes.

Run your find command on it every 30 minutes as well:

find / -newer /tmp/touch.me -print > /tmp/changed.files

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Arturo Galbiati
Esteemed Contributor

Re: Find command - find files changed within the last 30 minutes

Hi Kevin,
this should run. I'm writing should because I have no access to any box to test it.

perl -e 'while (<*>) { print "$_\n" if 1/48 > -M }

look for any file in current dir changed 30 minutes ago. Instead of <*> you can use <*.log> or anything else to reduce your search.
1/48 means a day divide by 48 = 30 minutes. If I well remmeber you can use always decimal value. Read Perl help for this.

HTH,
Art
James R. Ferguson
Acclaimed Contributor

Re: Find command - find files changed within the last 30 minutes

Hi Kevin:

Depending on the frequencey with which you need to perform this task, I too might choose a Perl solution that intrinsically computes 30-minutes ago without having to create a reference file for 'find'.

Art's solution will work for both files *and* directories but will not descend subdirectories as 'find' will do.

To have the best of everything you might do:

# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -M _ < 1/48},".")'

This will find only *files* in the current working directory that have been modifed during the last 30-minutes.

Regards!

...JRF...