LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copying bulk files from one server to another (https://www.linuxquestions.org/questions/linux-newbie-8/copying-bulk-files-from-one-server-to-another-835335/)

jegaraman 09-30-2010 12:21 AM

Copying bulk files from one server to another
 
HI ALl,

I need to copy a large number of files , it comes to 1 lakh from one server to another.

When i tried various commands using scp , ftp etc

It is saying "Arg list too long"

So Kindly help me in which way can we copy all the files.

The Two servers are under Linux.

Rgds
Jack

david1941 09-30-2010 12:39 AM

That error happens because your argument list exceeds the limit set by the system. xargs is your friend here. cat filelist |xargs scp ......

prayag_pjs 09-30-2010 12:43 AM

The "Argument list too long" error, which occurs anytime a user feeds too many arguments to a single command, since all regular system commands are subject to the some limitation.

There are several solutions:

Example: Here we are trying to move large number of files.

1.Manually spilt the command line arguments,but you have many arguments so this method wont support

2.Using find command

Quote:

find $directory -type f -name '*' -exec mv {} $directory2/. \;
It is filtering 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, successful and quite popular. 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.

3.Create a function

Quote:

function large_mv ()
{ while read line1; do
mv directory/$line1 ../directory2
done
}
ls -1 directory/ | large_mv
By writing a function you also gain the ability to perform an unlimited number of actions per file still using a single command.

4.Recompile the Linux kernel
involves manually increasing the number of pages that are allocated within the kernel for command-line arguments. If you look at the /usr/include/linux/binfmts.h file, you will find the following near the top:

Quote:

/*
* MAX_ARG_PAGES defines the number of pages allocated for arguments
* and envelope for the new program. 32 should suffice, this gives
* a maximum env+arg of 128kB w/4KB pages!
*/
#define MAX_ARG_PAGES 32
In order to increase the amount of memory dedicated to the command-line arguments, you simply need to provide the MAX_ARG_PAGES value with a higher number. Once this edit is saved, simply recompile, install and reboot into the new kernel as you would do normally.

jegaraman 10-07-2010 07:07 AM

Hi all

Thanks for your reply for every body

It was resolved by using xargs

dv502 10-07-2010 08:22 AM

Mark the thread SOLVED via the thread tools.


All times are GMT -5. The time now is 10:36 PM.