Operating System - HP-UX
1831101 Members
2933 Online
110019 Solutions
New Discussion

/usr/bin/find argument list too long

 
Frank de Vries
Respected Contributor

/usr/bin/find argument list too long

This is mind boggling.

We have a script running for months to
do a bit cleanup in the /tmp.

And since yesterday it produced/usr/bin/find argument list too long.
I checked the modification date of script,
and that was nov 6 as expected.

When I replayed the find command on the command line I could reproduce consistently.

What is even more strange that there are only
6 files that fit the criteria see below.
Okay, there are 871 files in /tmp, could that be the reason, when we try so hard to narrowing it down.

Even when I increased mtime to say +15,
so is should not find any, it complaint
that argument list is too long.

output from this morning:
[root@oradb1:]/tmp<>>> find /tmp/* -name "del*" -type f -prune -mtime +1 -print -exec rm {} \;
sh: /usr/bin/find: The parameter list is too long.
[root@oradb1:]/tmp<>>> cd /tmp
[root@oradb1:]/tmp<>>> ls -altr | wc -l
871
[root@oradb1:]/tmp<>>> find /tmp/* -name "del*" -type f -prune -mtime +4 -print -exec rm {} \;
sh: /usr/bin/find: The parameter list is too long.
[root@oradb1:]/tmp<>>> find /tmp/* -name "del*" -type f -prune -mtime +14 -print -exec rm {} \;
sh: /usr/bin/find: The parameter list is too long.
[root@oradb1:]/tmp<>>> find /tmp/* -name "del*" -type f -prune -mtime +15 -print -exec rm {} \;
sh: /usr/bin/find: The parameter list is too long.
[root@oradb1:]/tmp<>>> find /tmp/* -name "del*" -type f -prune -mtime +15 -print
sh: /usr/bin/find: The parameter list is too long.
[root@oradb1:]/tmp<>>> ls -altr /tmp/del*
-rw-rw-rw- 1 rvs users 0 Mar 26 08:00 /tmp/del_file.out
-rw-rw-rw- 1 rvs users 0 Mar 26 08:00 /tmp/del_file.err
-rw-rw-rw- 1 root sys 0 Mar 27 04:05 /tmp/del_dbe.d0032a.out
-rw-rw-rw- 1 root sys 0 Mar 27 04:05 /tmp/del_dbe.d0032a.err
-rw-rw-rw- 1 rvs users 0 Mar 27 06:50 /tmp/delete_bingo.err
-rw-rw-rw- 1 rvs users 0 Mar 27 06:50 /tmp/delete_bingo.out

Only 6 files match the -name "del*"
Look before you leap
7 REPLIES 7
Robert-Jan Goossens_1
Honored Contributor

Re: /usr/bin/find argument list too long

Hi Frank,

Try this one.

find / -path '/tmp/*' -name "del*" -type f -prune -mtime +15 -print | xargs rm

Regards,
Robert-Jan
Steven Schweda
Honored Contributor

Re: /usr/bin/find argument list too long

Is there some reason that plain "/tmp" would
be wrong?

find /tmp [...]
Frank de Vries
Respected Contributor

Re: /usr/bin/find argument list too long

Thanks for the input,
your command did not run
but a slight modification made it fly:

find /tmp -path '/tmp/*' -name "del*" -type f -prune -mtime +0 -print

Thanks
Look before you leap
Frank de Vries
Respected Contributor

Re: /usr/bin/find argument list too long

Ok it works now
Look before you leap
Steven Schweda
Honored Contributor

Re: /usr/bin/find argument list too long

> Only 6 files match the -name "del*"

The problem is that "/tmp/*" is too big, not
that "/tmp/del*" is too big. Your command
doesn't say "/tmp/del*", it says "/tmp/*".
(And, without the quotation marks, the shell
tries to expand "/tmp/*".)
Hemmetter
Esteemed Contributor

Re: /usr/bin/find argument list too long

Hi Frank

try your find statement with
-exec rm {} \+ # backslash plus

SEE find(1) section -exec:

When + is used, cmd aggregates a set of path names and executes on the set. Any command arguments between the first occurrence of {} and + are ignored. The reason for preferring + to a ; is vastly improved performance.

rgds
HGH
Frank de Vries
Respected Contributor

Re: /usr/bin/find argument list too long

ok
Look before you leap