Hi, everyone. Could you help me with deletion of files, which are 20 minutes old.
I found out how to make deletion for files in that way :
find <dir> -mtime n -exec rm -rf "{}"
Could you offer your suggestions.
Many thanks in advance.
Hi, everyone. Could you help me with deletion of files, which are 20 minutes old.
I found out how to make deletion for files in that way :
find <dir> -mtime n -exec rm -rf "{}"
Could you offer your suggestions.
Many thanks in advance.
mtime measures in hours, for minutes use mmin. If your find doesn't have mmin, 1 hour may be the best you can do with find.
You are missing the ';' parameter on the end that tells -exec when to stop.
I'd put {} into single quotes instead of double in case the shell tries to parse it into some sort of statement.
The -r parameter to rm is only needed for recursively deleting directories. If you're only deleting files, give yourself some extra safety by leaving it off.
find dir -mmin 20 -exec rm -f '{}' ';'
Corona688, thanks a lot. I don't have parameter mmin in Solaris10, can you explain how I suppose to use an hour time period? Is it like find dir -mtime 0.025 -exec rm -f '{}' ';'??
Yep, you cannot do that way.
It requires a non fractional number.
Touch a dummy file and find all file older that dummy.
Search the forum for solution.
Further to danmero.
At the time of creation:
touch 20_minutes_ago
then 20 minutes later:
find <dir> -type f ! -newer touch_20_minutes_ago -exec echo "{}" \;
Replace "echo" with your "rm" command if you are happy to delete the files.