Operating System - HP-UX
1833776 Members
1882 Online
110063 Solutions
New Discussion

find and delete not working

 
SOLVED
Go to solution
Paul Sperry
Honored Contributor

find and delete not working

Iam doing a massive oracle import and want to get rid of the archive logs every five minutes. My cron entry looks like the following:

00,05,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/find /u05/archlogs -type f -name *.ARC -exec /usr/bin/rm -f {} \;

But it dosen't appear to be working.
The files in /u05/archlogs look like archT0001S00000123436.ARC

hp-ux 11.11

Not sure what Iam missing

TIA
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: find and delete not working

Your problem is -name *.ARC which should be expressed as -name "*.ARC" or -name '*.ARC'. You want find rather than the shell to expand the metacharacter so you must protect the target string with quotes.
If it ain't broke, I can fix that.
Paul Sperry
Honored Contributor

Re: find and delete not working

silly me cron wasn't running
Geoff Wild
Honored Contributor

Re: find and delete not working

Clay is right - this is one I have:

find /usr/sap/SID/D*/data -name "SP*" -mtime +3 -exec rm {} \; >/dev/null 2>&1


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
James R. Ferguson
Acclaimed Contributor

Re: find and delete not working

Hi:

On another note, if you want a less-intensive (faster) process, change:

# ... -exec /usr/bin/rm -f {} \;

to:

# -exec /usr/bin/rm -f {} \+

This bundles up filenames to spawn many less processes. A corollary implementation would be:

# ... | xargs rm -f {}

Regards!

...JRF...
Paul Sperry
Honored Contributor

Re: find and delete not working

thanks for verifing Geoff.

And thanks for the info James
Paul Sperry
Honored Contributor

Re: find and delete not working

Some how my thanks to Clay dissapeared.
Must have been when I reopened to assign more points.

Thanks again Clay