“Argument list too long” on Linux

January 26th, 2009 Posted in Oracle How-To

Ever get the error “Argument list too long” when working with files on Linux? I deal with a lot of files from telecommunication switches. These files contain call detail records (CDRs). I generally load these files into an Oracle database using sqlldr.

These files ad up quickly and space is valuable on the server. I need to get these files off to tape. Moving these files around I run into the error “Argument list too long”. This error will affect all regular system commands (ls *, cp *, rm *, etc…).

I filter the list of files through the find command, instructing it to properly handle each file based on a specified set of command-line parameters. Due to the built-in flexibility of the find command, this workaround is easy to use. It allows you to selectively work with subsets of files based on their name patterns, date stamps, permissions and even inode numbers. In addition, and perhaps most importantly, you can complete the entire task with a single command.

The main drawback to this method is the length of time required to complete the process. This procedure actually inspects the individual properties of each file before performing the designated operation. The overhead involved can be quite significant, and moving lots of files individually may take a long time. Here is the command I use to move the files.

[user@server1 archive]$ find $archive -type f -name '*'
-exec mv {} /old_array/backup/acme/. \; 

Leave a Reply