In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what to do when there are Argument list too long errors in linux. I hope you will get something after reading this article. Let's discuss it together.
1. Error phenomenon
This is a Mysql database server that runs a lot of scheduled tasks in the system. Today, another scheduled task was added through the crontab command. The following error occurred when exiting:
# crontab-e
After editing, save and exit, and the error shown in the following figure appears:
2. Solution
According to the error message above, it is basically determined that the disk space is full, so first check the disk space of the server, then check / tmp disk space first according to the error prompt, and then check the disk space of the root partition, preferably the disk space of other partitions of the system.
3. Troubleshooting
Check all the disk partitions on this server through the df command. There is still a lot of space in / tmp partition, and there is also a lot of space left in the root partition, so there is no problem. Finally, it is found that the use of / var disk partition space is already 100%. The problem has been located here, which is caused by the full disk space of / var, because crontab will write file information to the / var directory when saving, because this disk has no space. It's only natural to report a mistake.
4. Solve the problem
Then check the size of all files or directories under the / var directory through the "du-sh" command, and find that the / var/spool/clientmqueue directory occupies 90% of the entire partition size of / var, so how are the files under the / var/spool/clientmqueue directory generated and can they be deleted? The following is a brief description of how the files in the / var/spool/clientmqueue directory are generated.
You can open some files under the / var/spool/clientmqueue directory to have a look. They are all email messages. Most of the emails are about Cron Daemon. In fact, / var/spool/clientmqueue is a directory where emails are temporarily stored. The linux server will send some emails by default. For example, when the programs executed by cron have output, they will send email messages to the users who execute the cron process. When the system sends emails, it will send messages to the users who execute the email process. The mail is first copied to the / var/spool/clientmqueue directory and then waited for the MTA program (mail transfer agent) to process it, while the main function of MTA is to transfer the mail from this directory to the / var/spool/mqueue directory and then send it to the real destination through the sendmail service. So I checked the server's sendmail service and found that it was not turned on, so the reason why the / var/spool/clientmqueue directory was very large was found: there was no client service that sent mail, and all the messages were piled in this directory.
After confirming that these contents are useless, change to the / var/spool/clientmqueue directory and execute the rm command to delete all files, and an error occurs:
[root@localhost clientmqueue] # rm * / bin/rm: argument list too long
At this point comes the problem we talked about at the beginning of this article.
A "Argument list too long" error occurs when trying to pass too many parameters to a system command under Linux. This is a limitation that Linux systems have always had. You can view this limitation by using the command "getconf ARG_MAX", as shown in the following figure:
This is a maximum value for the Centos6 version, while in Centos5.x, this value is relatively small, as shown in the following figure:
So this problem occurs more often in the lower version of linux.
Knowing the cause of the problem, there are many solutions. Here are four ways to solve the problem, which are described as follows:
(1) manually divide the command line parameters into smaller parts
For example:
Rm [a Murn] *-rfrm [Omurz] *-rf
This method is the simplest, but relatively retarded, because you have to know how to divide files evenly, and in the case of a large number of files, you need to enter commands many times.
(2) use find command to delete
The basic principle is to filter the list of files through the find command and pass the files that meet the requirements to a series of commands. This method is the simplest and most effective.
For example:
Find / var/spool/clientmqueue-type f-print-exec rm-f {}\
But this approach also has the drawback: it needs to traverse all the files, so it is time-consuming when the number of files is very large.
(3) through shell script
This approach is done by writing a shell script and then through sequential statements, similar to the find method.
For example, you can write a script like this:
#! / bin/bash# configure the folder RM_DIR='/var/spool/clientmqueue'cd $RM_DIRfor I in `ls`do rm-f $Idone to be deleted
(4) recompile the Linux kernel
This method requires manually increasing the number of pages in the kernel assigned to command-line arguments, open the include/linux/binfmts.h file under kernel source, and find the following line:
# 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 complex and is recommended for advanced users. It is not recommended for users with no Linux experience.
After reading this article, I believe you have a certain understanding of "what to do with Argument list too long errors in linux". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.