The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find files older than 2 hours pt14 AIX 3 03-05-2008 12:31 PM
Deleting Files Older than 24 hours mazhar803 SUN Solaris 7 09-27-2007 07:30 AM
removing files after 6 hours or older gthokala Shell Programming and Scripting 3 08-22-2005 10:59 PM
Finding only those files older than 2 hours mh53j_fe UNIX for Dummies Questions & Answers 2 07-01-2005 09:33 AM
Finding files older than 2 hours ianf Shell Programming and Scripting 1 05-27-2002 10:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-14-2005
Presanna Presanna is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 1
unix command/s to find files older than 2 hours in a directory

I need to write a script to find files older than 2 hours in set of direcotries and list them ina mail. I know find command ti list files greater/lesser than days but i need to do it for hours. Any input.
  #2 (permalink)  
Old 08-15-2005
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
You need to use GNU find or some other find that supports some extra options... with GNU find the -amin, -cmin and -mmin deal in minutes rather than days.
  #3 (permalink)  
Old 08-15-2005
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,716
try using touch to set a filetime on a dummy file, then use the ! -newer option
Code:
touch -t [[CC]YY]MMDDhhmm[.SS] somefile 
find . ! -newer somefile -print
  #4 (permalink)  
Old 08-17-2005
frustrated1 frustrated1 is offline
Registered User
  
 

Join Date: Aug 2003
Location: Ireland
Posts: 278
GNU find is brilliant - I would go with this..
  #5 (permalink)  
Old 08-17-2005
rein rein is offline
Registered User
  
 

Join Date: Dec 2004
Location: Zürich
Posts: 146
This issue seems to pop a lot lately. Another solution is using awk:

ls -l | awk '{if($8 > 2) print $9}' | xargs rm

or something like that does the trick as well. You can combine filters like:

if($6 == Jul && $7 == 11 && $8 > 2)

to find all files of july 11, created or modified after 2 o'clock.
  #6 (permalink)  
Old 11-20-2007
neeljeet6 neeljeet6 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 1
find $DM_CTL_DIR -type f -mmin +120

will delete all files older than 2 hrs..
  #7 (permalink)  
Old 11-20-2007
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Similar to the clauses "-atime", "-ctime" and "-mtime" there are "-amin", "-cmin" and "-mmin" which take minutes instead of days as operands. At least the find in AIX works that way. Here is an excerpt from "man find" (AIX 5.3):

Code:
       -amin Number
            Evaluates to the value True if the file has been accessed in
            Number-1 to Number minutes. For example, -amin 2 is true if the
            file has been accessed within 1 to 2 minutes.
       -cmin Number
            Evaluates to the value True if the file i-node (status
            information) has been changed in the specified number of minutes.
       -mmin Number
            Evaluates to the value True if the file has been modified in
            Number-1 to Number minutes
bakunin
Sponsored Links
Closed Thread

Bookmarks

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0