Results 1 to 2 of 2
I have written this script to delete files from a directory that are older then two days.
find /Library/Webserver/Documents/caches/download/ -mtime +2 -exec rm {*.zip} \: -print.
I would trigger this ...
- 03-24-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 1
Script Testing
I have written this script to delete files from a directory that are older then two days.
find /Library/Webserver/Documents/caches/download/ -mtime +2 -exec rm {*.zip} \: -print.
I would trigger this with Crontab.
I would like to test this by producing a log file of what would have been deleted without actually deleting anything. Is this possible?
- 03-24-2008 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
The best thing to do with find is to change the exec command so that it will only echo or print the output. Also I would recommend using the iname switch rather than letting rm figure it out.
When you decide to add this to your crontab make sure you put in the full path to find and if outputting anything make sure you expand to full paths i.e. /home/jpawski rather than ~.Code:find /Library/Webserver/Documents/caches/download/ -iname *.zip -mtime +2 -exec echo {} > ~/find_test \;


Reply With Quote