If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > To delete files not currenlty used

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-12-03, 06:33
inderpal inderpal is offline
Registered User
 
Join Date: Nov 2003
Location: India
Posts: 2
Post To delete files not currenlty used

Hi All
Iam currently facing a problem wherin i need to delete files *.log older than 14 days in a directory but exclude files which are currently not being open/used by any processes. can someone help me with the script????
I understand that using
find /app/minotaur/Log -atime 14 -exec rm {} \;
will remove all files whose acess timeisless than 14 days but wat abt those files which are not been written into for past 14 days but are still opened by some process

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 11-12-03, 09:53
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Re: To delete files not currenlty used

Quote:
Originally posted by inderpal
Hi All
Iam currently facing a problem wherin i need to delete files *.log older than 14 days in a directory but exclude files which are currently not being open/used by any processes. can someone help me with the script????
I understand that using
find /app/minotaur/Log -atime 14 -exec rm {} \;
will remove all files whose acess timeisless than 14 days but wat abt those files which are not been written into for past 14 days but are still opened by some process

Thanks in advance
Hi,

You tested with mtime, instead atime.

Gustavo.
Reply With Quote
  #3 (permalink)  
Old 11-12-03, 23:26
inderpal inderpal is offline
Registered User
 
Join Date: Nov 2003
Location: India
Posts: 2
hello gustavo
yeah even mtime can be used.but i have asituation wherein something is written into the log file only when there is an error,So if i blinldy use mtime or atime i wil even delete those files which are currently opened by my application and the application is running without error for last 14 days.So i need a script which will only delete log files which are not opened by any application and are 14 days old.
Thanks
Reply With Quote
  #4 (permalink)  
Old 11-13-03, 14:23
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi inderpal,
I think there is no solution for your problem. If you can edit the program
(source code) make a touch dayly to the file or open every day a new file whith date in the filename. Exampe "myprog[mmddyy].log"
Then your "find bla bla" will works.
__________________
Greetings from germany
Peter F.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On