./foo: /usr/bin/ls: 0403-027 The parameter list is too long.
A program has been running for months on your IBM® AIX® computer without issue. But while the program is running, it creates a file every few minutes in the same directory for logging. The file names begin with f.ls command is slowing down drastically on response time. That is understandable, because the directory has so many files in it.
A few more months go by, and the AIX program continues to run consistently and without problem. There are now 100,000 files that begin with f. and another 100,000 files that begin with e. Now, when you attempt to clean up the log directory of only the files that begin with f., you receive the following message:
# rm ~cormany/logs/f.* |
I guess you waited too long before cleaning up the files. No time like the present, however.
When executing a command like delete, all arguments are validated and expanded before execution. The example provided is looking for ~cormany/logs/f.*, which expands to become 100,000 arguments to the command rm. In other words, instead of rm ~cormany/logs/f.*, what is actually being executed is rm ~cormany/logs/f.1 ~cormany/logs/f.2 ~cormany/logs/f.3 … ~cormany/logs/f.100000.
AIX, like other UNIX and Linux operating systems, has a set size for the number of command-line arguments and environment variables that can be used. To view the set size in AIX, use the command getconf. Per the man page for getconf, you should look at ARG_MAX:
# man getconf |
This value tells you that you have 1,048,576 bytes you can use for environment variables and command-line arguments to execute. It looks like you exceeded that. To resolve this issue, two options are available:
- Increase the amount via
smitty chgsysand changeARG/ENV list size in 4K byte blocksor viachdev. I do not recommend changing a system-wide parameter every time you run into this type of error out of convenience: This should be the last resort. - Rather than using the command
rmwith 100,000 arguments, which will fail miserably, the commandfinddoes a much better job of removing the files:# find ~cormany/logs –name “f.*” –exec rm {} \;
The
findcommand searches the directory for any files beginning with f. rather than placing the burden on the shell's command line. Thefindcommand then executesrmon each file found, thus removing every file beginning with f.
By the way, xargs can be another alternative (may be the first) for resolving this issue, as well. Today, I experience a problem with a script which gives the error; \script[5]: no space. Using xargs also resolves this issue (actually the main problem is the too many file names in the find command, find .... | xargs ls can also solve the problem but, changing the first line to #!/bin/bsh also solves the problem)
* The whole article can be accessed from http://www.ibm.com/developerworks/aix/library/au-unixerrors/index.html
If you wanna save some brain power just do it this way.
ReplyDeleteFrom windows command line
ftp -i [insert server name]
login
cd /cormany/logs
mdelete f.*
Many ways to skin a cat and all that.