Welcome to WebmasterWorld Guest from 54.146.201.80

Forum Moderators: bakedjake

Message Too Old, No Replies

cron: find and remove without return error

     
5:30 pm on Nov 18, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 20, 2003
posts:144
votes: 0


Hello

I have setting a cron that lunch this code any 60 minutes:

find /home/myhone/public_html/files -cmin +60 -exec rm -rf {} \;

all perfect.. but I received message:

find: /home/myhome/public_html/files: No such file or directory

when cron don't find anything..

is possible to not receive this message?

tx

10:44 pm on Nov 18, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


To ignore the errors, just put:
> /dev/null 2>&1
at the end of the command.

But, that command is removing the files directory itself, which I don't think you want. Using this intead, you shouldn't have any errors:

find /home/myhome/public_html/files/* -depth -cmin +60 -exec rm -rf {} \;