Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (18)
As of 2015-07-28 19:05 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (258 votes), past polls