Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Keep It Simple, Stupid
 
PerlMonks  

Re: Deleting Files

by RobPayne (Chaplain)
on Oct 07, 2006 at 19:17 UTC ( #576893=note: print w/ replies, xml ) Need Help??


in reply to Deleting Files

Joost and the others have already provided working examples of tools which do what you have asked. The caveat with this operation is to be careful enough to not get bitten by the same types of bugs that have bitten others in this case. (You need to make sure that you adequately escape special characters in file names, quoting spaces, etc. so you don't, for example, call rm on a file named "/server/dir /etc/passwd" with that space in the name. You didn't mention what platform you were running on, but you might want to take a look at utilities that have already solved this problem and have already learned some of the lessons associated with this operation. One such utility is 'tmpwatch', which is included with redhat-based linux distros.

Tmpwatch uses -atime instead of -mtime as the basis for how old a file is and whether it is ready to be deleted. That way you don't remove files that haven't been written to, which are still being read by current processes.


Comment on Re: Deleting Files

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://576893]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-04-23 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls