Argument list too long ...

Source: Internet
Author: User

As an OPS person, this error is not unfamiliar, in the implementation of RM, CP, MV and other commands, if the number of files to operate, you may use the wildcard character batch processing a large number of files, then there may be "Argument list too long" this issue.

1. Error phenomena

This is a MySQL database server, running a lot of scheduled tasks in the system, today through the crontab command and add a scheduled task, exit when the following error occurred:

1 #crontab -e

After editing is complete, save exit, and the following error appears as shown:

2, solve the idea

According to the above error message, the basic decision is that the disk space is full, then first from the check server disk space, according to the error prompt should first check/TMP disk space, and then should be the root partition disk space, preferably the other partition of the system disk space.

3. Troubleshooting

Through the DF command to see all the disk partitions on this server,/TMP partition space, there are many, the root partition also has a lot of space, there is no problem, and finally found that the/var disk partition space use has been 100%, to this point has been fixed the problem, is the/var disk space is full caused, Because the crontab will write the file information to the/var directory at the time of saving, because the disk has no space, the error is taken for granted.

4, solve the problem

Then through the "du-sh" command to check the size of all files or directories under the/var directory, and found that the/var/spool/clientmqueue directory occupies 90% of the total partition size of/VAR, then/var/spool/ How are the files in the Clientmqueue directory generated, and can I delete them? Below is a brief description of how the files of the/var/spool/clientmqueue directory are generated.

Can open some files under the/var/spool/clientmqueue directory to see, are some mail messages, the content of the message is mostly about cron daemon, in fact,/var/spool/clientmqueue is a mail staging directory, Linux server will send some mail by default, such as when Cron executes the program has output content, it sends the mail message to the user who executes the cron process, the system sends the mail, the message first will be copied to the/var/spool/clientmqueue directory, Then wait for the MTA program (mail transfer agent) to process, and the main function of the MTA is to transfer the contents of this directory to the/var/spool/mqueue directory, and then send to the real destination through the SendMail service. So check the server's SendMail service, found not open, so the/var/spool/clientmqueue directory is very large reason to find: No mail client service, all the messages are piled up in this directory.

After confirming that the content is useless, switch to the/var/spool/clientmqueue directory, execute the RM command to delete all the files, an error occurred:

12 [[email protected] clientmqueue]# rm */bin/rm: argument list too long

At this point, we are talking about the problem at the beginning of this article.

"Argument list too long" error occurs when Linux tries to pass too many parameters to a system command. This is a limitation of the Linux system all along. Viewing this restriction can be achieved by command "getconf Arg_max", as shown in:

This is a maximum value for the CENTOS6 version, and in centos5.x, the value is relatively small, as shown in:

So this problem is more often happening in the Linux low version.

Knowing the cause of the problem, there are a lot of solutions, here are four ways to solve this problem, respectively, the following:

(1) Manually dividing the command line parameters into smaller parts

For example:

12 rm[a-n]* -rfrm[o-z]* -rf

The simplest of these methods, but relatively weak, because you have to know how to divide the file evenly, and for a large number of cases, you need to enter many times command.

(2) Use the Find command to delete

The rationale is to filter the list of files with the Find command and pass the required files to a series of commands. This approach is the most concise and most effective.

For example:

1 find/var/spool/clientmqueue -type f -print -exec rm-f {} \;

But this approach also has drawbacks: it is necessary to traverse all the files, so it is time-consuming to have a very large number of files.

(3) Through shell scripts

This approach is done by writing a shell script and then implementing it in a sequential statement, similar to the Find method.

For example, you could write the following script:

/tbody>
12 #!/bin/bash #  set the folder to be deleted
123456 RM_DIR=‘/var/spool/clientmqueue‘cd$RM_DIRfor in `ls`do rm-f $Idone

(4) Recompile the Linux kernel

This method needs to manually increase the number of pages allocated to the command line parameters in the kernel, open the Include/linux/binfmts.h file under kernel Source, and locate the following line:

1 # define MAX_ARG_PAGES  32

Change "32" to a larger value, such as 64 or 128, and then recompile the kernel.

This method is permanent and can solve the problem completely, but it is more complicated and recommended for advanced users, and it is not recommended for users without Linux experience.

This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://ixdba.blog.51cto.com/2895551/1433379

Argument list too long ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.