Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

cron: find and remove without return error



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

10+ Year Member


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?



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

WebmasterWorld Senior Member 10+ Year Member

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 {} \;


Featured Threads

Hot Threads This Week

Hot Threads This Month