rm or find on Linux: "Argument list too long"
So you're trying to delete a huge list of files and seeing this error. It's a limitation of your kernel, because your OS cannot handle too many files at once.
The solution is simple. Use the following command:
find . -name 'dos-*' -print0 | xargs -0 rm
Where "dos-" is a string contained in the files you wish to delete. That should do it.
Suggestion: for log folders that fill up quickly, e.g., the logs of a database or Apache modules such as mod_evasive, it's usually a good idea to automatically remove the files older than a certain number of days. For instance, to remove all log files in the mod_evasive folder older than 2 days, use this command in the crontab:
01 01 * * * find /var/log/apache/mod_evasive/* -mtime 2 -exec rm {} \; > /dev/null 2>&1
RECENT COMMENTS