Results 1 to 4 of 4
Hi guys I got this part from my script working that it will delete a folder is from 8 days ago
EightDaysAgo=`(date --date="8 days ago" +%d-%m-%Y)`
rm -rf $EightDaysAgoTar
However ...
- 03-31-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 19
What to write synatax to delete stuff older than 8 days
Hi guys I got this part from my script working that it will delete a folder is from 8 days ago
EightDaysAgo=`(date --date="8 days ago" +%d-%m-%Y)`
rm -rf $EightDaysAgoTar
However I need to remove files that are older than 8days for example if the script is'nt run for a day it will remove both the 9th and 8th day one not just the 8th day one. If I'm making any sense lol
Thanks in advanced
- 03-31-2011 #2
You could try the below:
The above should find all files 8 days or older in desired directory and delete them. Does this achieve what your looking to do?Code:find /location/of/files -type f -mtime +8 | xargs rm
- 03-31-2011 #3
+1 Nagarjuna
but maybe it makes sense to include -name to not accidentally delete the wrong files.
Match the name as closely as possible.
Code:find /location/of/files -type f -name "*.tar" -mtime +8 -delete
You must always face the curtain with a bow.
- 04-01-2011 #4Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
For the sake of your own sanity, please check the consequences of any destructive command before committing to it.
Code:find /location/of/files -type f -name "*.tar" -mtime +8 -print


Reply With Quote