Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun May 30, 2004 1:41 pm 
Offline
Senior Newbie
User avatar

Joined: Wed Oct 15, 2003 12:49 pm
Posts: 14
Hi,

I would like to be able to delete a file after 30mins, what would the could be for that to check to make sure it 30mins and older ?

Regards,
Garry

_________________
Regards,
Garry


Top
   
 Post subject:
PostPosted: Sun May 30, 2004 8:15 pm 
Offline
Senior Newbie

Joined: Fri May 28, 2004 3:01 pm
Posts: 15
put that in crontab :)
Code:
0/30 * * * * rm file


Top
   
 Post subject:
PostPosted: Mon May 31, 2004 3:43 am 
Offline
Junior Member

Joined: Tue Nov 18, 2003 2:02 am
Posts: 30
That won't work. Say the file gets created at 00:20. Ten minutes later, at 00:30, the file gets removed, but it was only ten minutes old.

If it's a regular file, try

Code:
find filename -cmin +30 -print | xargs rm


find will only output the filename if it was created at least 30 minutes ago (technically, if its ctime is more than 30 minutes ago), so if the file is newer, its filename doesn't get piped to xargs.


Top
   
 Post subject:
PostPosted: Mon May 31, 2004 6:03 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
smerritt wrote:
Code:
find filename -cmin +30 -print | xargs rm


A minor gotcha with this; if you can't trust the filenames (eg someone else could have put them in) then use "-print0" and "xargs -0" because filenames with spaces, embedded returns or other funny characters could cause problems.

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group