Re: File delete script not working
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Sat, 19 Aug 2006 00:47:32 -0400
On 2006-08-19, Allen Kistler wrote:
mydejamail@xxxxxxxxxxx wrote:
I having a problem applying this script, it just doesn't seem to work.
The purpose is to delete all files over 30 days old. The directories
are 1,2,3,4,5.
Can anyone who knows about find and xargs please help.
It does not from the command line or a cron job.
cd /var/www/html/zm/events
find 1 -type f -mtime +30 | xargs rm -f
find 2 -type f -mtime +30 | xargs rm -f
find 3 -type f -mtime +30 | xargs rm -f
find 4 -type f -mtime +30 | xargs rm -f
find 5 -type f -mtime +30 | xargs rm -f
Why not:
find [12345] -type f -mtime +30 -exec rm -f {} \;
Because that would be very slow, because it calls rm for every file
found. If you have the latest version of find, this will be much
faster:
find 1 2 3 4 5 -type f -mtime +30 -exec rm -f {} +
Otherwise:
find 1 2 3 4 5 -type f -mtime +30 -print0 | xargs -0 rm -f
(But we still don't know what the OP's problem was.)
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.
- Follow-Ups:
- Re: File delete script not working
- From: mydejamail
- Re: File delete script not working
- References:
- File delete script not working
- From: mydejamail
- Re: File delete script not working
- From: Allen Kistler
- File delete script not working
- Prev by Date: Re: Cups pauses after 6 jobs
- Next by Date: Re: Trying to get Pan compiled and working in Fedora core 4
- Previous by thread: Re: File delete script not working
- Next by thread: Re: File delete script not working
- Index(es):
Relevant Pages
|