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
delete files older than 5 minutes in directory (recursively) scarfake Shell Programming and Scripting 3 06-13-2008 02:10 AM
Reg: delete older files from ftp sam99 UNIX for Dummies Questions & Answers 3 01-09-2008 10:56 AM
delete files and folders older than 3 days melanie_pfefer Shell Programming and Scripting 7 12-18-2006 12:58 PM
How can I delete files older than 7 days? odogbolu98 UNIX for Dummies Questions & Answers 3 02-26-2002 08:35 PM
delete files older than 7 days lesstjm UNIX for Dummies Questions & Answers 1 11-06-2001 10:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2008
psiva_arul's Avatar
psiva_arul psiva_arul is offline
Registered User
  
 

Join Date: Jul 2007
Location: Bangalore, India
Posts: 97
how to delete the files which are the 30 min older...?

Hi all,

i have a simple question that i want to find out the 30 minutes older files and delete those files from the particular location(Folder)

Generally for this purpose used to retreive the files with "atime" command

For example: find and delete the 2 days older log files use this below command

find $HOME/Log -type f -name "*.log" -atime+2 -exec {} \;

But how can use for 30 min older files...?

Suggession are apprciated.

Thanks and Regards,
MPS
  #2 (permalink)  
Old 06-13-2008
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,429
Use *min for minutes.
Code:
find $HOME/Log -type f -name "*.log" -amin +30 -exec ls {} \;
  #3 (permalink)  
Old 06-13-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,764
If the OP is on Linux or has GNU find -amin works

Otherwise try:
Code:
#!/bin/ksh
# filetimes
filetime()
{
    perl  -e '
          $mtime = (stat $ARGV[0])[9];
          print $mtime
         ' $1
}
now=$(date +%s)
limit=$(( $now - 1800 ))  # one half hour ago.

find /path/to/files -type f |\
while read filename 
do
	dt=$(filetime  $filename)
	if [[ $dt -lt $limit ]] ; then
   		rm -f $filename  # delete ALL files older then 30 minutes
   	fi
done
Closed Thread

Bookmarks

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 04:16 PM.


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