Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script help

Status
Not open for further replies.

ubihga

IS-IT--Management
Nov 28, 2005
25
DK
Hi

I have a problem running one of my script.

This commands end in error:
find /tmp -mtime +7 | xargs rm -fR

Some times we have many files in /tmp, the command gives error: 0403-027 The parameter list is too long.

How can i avoid this.

I can not reduce mtime because the files is often generated the same day.

The only way I have managed to do it is:
find /tmp/a* -mtime +7 | xargs rm -fR
find /tmp/b* -mtime +7 | xargs rm -fR
.
.
find /tmp/z* -mtime +7 | xargs rm -fR

Can this be done better ?


Thanks in advance.

/HGA




 
That's normal, it meens you have to many files corresponding to your criterias.

To have two solutions:

1) Change your script and do something like:

for i in `......`
do
rm $i
done


2) Else you have to change standard users memory allocation

in smit -> Change / Show Characteristics of Operating System


have a look to:

ARG/ENV list size in 4K byte blocks

And increase the number of 4Kb blocks allocated. But be careful with that, all your users will allocated this amount and then use more memory for each process running.

Sometime i change that for one hour to clean some directories like you and then put it back to the original value.
 
find /tmp -mtime +7 -exec rm {} \;

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Mike, I think -exec runs into the same limitation as xargs. Correct me if I'm wrong, however.

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
no Ken, "-exec rm {} \;" runs the rm for every file found.

But it might take longer than xargs.

This might also work:

find /tmp -mtime +7 -type f | xargs -n 100 rm -f

Does not remove dirs, as I'm assuming they would be recreated anyway. if you still get errors, try with an even lower xargs number...

you may want to test things out first:

find /tmp -mtime +7 -type f | xargs -n 100 echo



HTH,

p5wizard
 
Hi

Thanks all

I have desided to use "find /tmp -mtime +7 -type f | xargs -n 100 rm -f"

/HGA
 
Thanks p5wizard. However, I'm sure I've seen in this forum that the xargs construct is in fact preferable to -exec {} for long lists. Mind you, it has been a long Monday!!

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top