Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

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 romping around the Monastery: (5)
As of 2016-10-22 09:37 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.