AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

why error "parameter list too long" when develope script for copy files ?

  • 1.  why error "parameter list too long" when develope script for copy files ?

    Posted Tue May 26, 2009 06:44 AM

    Originally posted by: chandru0078


    hi gurus

    I' getting error "parameter list too long" when develope script for copy 1 day oldeer file from source directory to target .I cannot effort change the sys0 or chsys config.Can we do script to copy.inside target directoty have 15days logs before delete last copy and create new copy.

    source=/usr/cc/abc/mm/log/mm.trace.abc.11120.2009-05-25.txt copy to below path
    target dir=/usr/bbb/mmtracelog/
    find /usr/cc/abc/mm/log/mm.trace*.txt -mtime -1 -exec cp '{}' /usr/bbb/mmtracelog/ \;

    but why mtime -copy all older then today date?.how to make it copy only 1 days older then system date? pls help
    #AIX-Forum


  • 2.  Re: why error "parameter list too long" when develope script for copy files ?

    Posted Tue May 26, 2009 06:52 AM

    Originally posted by: tony.evans


    Don't you want,

    find /usr/cc/abc/mm/log/ -name "mm.trace*.txt" .........
    #AIX-Forum


  • 3.  Re: why error "parameter list too long" when develope script for copy files ?

    Posted Wed May 27, 2009 05:55 AM

    Originally posted by: chandru0078


    hi
    i have test that to its work but 1 problem is copying all under /usr/cc/abc/mm/log/ .i only want 1 day older then system day ?so try to export date by using steps b

    steps a
    1. find /usr/cc/abc/mm/log/ -name 'mm.trace*.txt' -exec cp '{}' /usr/bbb/mmtracelog/ \;
    2. cd /usr/bbb/mmtracelog/
    3. ls -lrt
    total 5162
    -rw-r--r-- 1 root system 6130 May 27 17:32 mm.trace.ATM00000195.11120.2009-05-23.txt
    -rw-r--r-- 1 root system 18378 May 27 17:32 mm.trace.ATM00000187.11120.2009-05-12.txt
    -rw-r--r-- 1 root system 2930 May 27 17:32 mm.trace.ATM00000184.11120.2009-05-24.txt
    -rw-r--r-- 1 root system 6130 May 27 17:32 mm.trace.ATM00000175.11120.2009-05-19.txt
    -rw-r--r-- 1 root system 24520 May 27 17:32 mm.trace.ATM00000175.11120.2009-05-18.txt
    -rw-r--r-- 1 root system 2930 May 27 17:32 mm.trace.ATM00000173.11120.2009-05-13.txt
    -rw-r--r-- 1 root system 6168 May 27 17:32 mm.trace.ATM00000164.11120.2009-05-21.txt
    -rw-r--r-- 1 root system 12260 May 27 17:32 mm.trace.ATM00000125.11120.2009-05-15.txt
    -rw-r--r-- 1 root system 6130 May 27 17:32 mm.trace.ATM00000090.11120.2009-05-21.txt
    -rw-r--r-- 1 root system 5706 May 27 17:32 mm.trace.ATM00000003.11120.2009-05-15.txt
    -rw-r--r-- 1 root system 153462 May 27 17:32 mm.trace.ATM00000001.11120.2009-05-26.txt
    -rw-r--r-- 1 root system 68422 May 27 17:32 mm.trace.ATM00000001.11120.2009-05-25.txt
    stpes b
    export time=`date +%Y-%m-%d`

    find /usr/cc/abc/mm/log/ -name 'mm.trace*$time.txt' -exec cp '{}' /usr/bbb/mmtracelog/ \;

    script completed without error but no files being copy ;(
    #AIX-Forum


  • 4.  Re: why error "parameter list too long" when develope script for copy files

    Posted Wed May 27, 2009 10:11 AM

    Originally posted by: Casey_B


    Here's a general debugging trick:
    use "set -x" to see how the shell has interpreted your command.
    In your case, my initial thought is that your quoting is incorrect.
    You can't have single quotes deny shell interpretation, and then expect your variable to be interpreted!

    Try this:
    set -x
    find /usr/cc/abc/mm/log/ -name mm.trace\*${time}.txt -exec cp {} /usr/bbb/mmtracelog/ \;

    (I also don't think you need the quotes around {})

    Hope this helps
    Casey
    #AIX-Forum


  • 5.  Re: why error "parameter list too long" when develope script for copy files

    Posted Wed May 27, 2009 10:12 AM

    Originally posted by: Casey_B


    Here's a general debugging trick:
    use "set -x" to see how the shell has interpreted your command.
    In your case, my initial thought is that your quoting is incorrect.
    You can't have single quotes deny shell interpretation, and then expect your variable to be interpreted!

    Try this:
    set -x
    find /usr/cc/abc/mm/log/ -name mm.trace\*${time}.txt -exec cp {} /usr/bbb/mmtracelog/ \;

    (I also don't think you need the quotes around {})

    Hope this helps
    Casey
    #AIX-Forum


  • 6.  Re: why error "parameter list too long" when develope script for copy files

    Posted Wed May 27, 2009 11:20 AM

    Originally posted by: hwyguy


    Another thing you can do is change the value of NCARGS if you have root access.

    AIX defaults to 6, but I set this to the max of 1024 in all of my servers and I've never received an "Arg List Too Long" with find, rm, cp, ls, etc since.

    You change this running the following command:

    chdev -l sys0 -a ncarcrgs

    Of course, if you're uncomfortable going to the 1024 max, you can increase the value little by little until the error disappears.
    #AIX-Forum


  • 7.  Re: why error "parameter list too long" when develope script for copy files

    Posted Wed May 27, 2009 11:35 AM

    Originally posted by: Emittim3@Sirius


    Like was said, the number of arguments limit is being exceeded in the shell. If you can't modify that, one of the tricks is to instead pipe the output of one command into another that executes on each line instead of attempting to execute on a list of arguments all in one command. So you could try piping the results of the find into a set of awk and xargs commands, or perform the operation in a shell loop instead of in the -exec portion of the find command.

    Example:

    find /home -name '*.core' -exec rm -f {} \;

    <blork!!! argument list too long!!!>

    could be re-written with:

    find /home -name '*.core' | xargs -l1 rm -f

    (should work, although I'm doing this from somewhat memory - but it should at least give you the idea.... if piping to xargs doesn't do it, you could perform in in a loop:)

    for x in `find /home -name '*.core'`
    do
    rm -f $x
    done
    #AIX-Forum


  • 8.  Re: why error "parameter list too long" when develope script for copy files

    Posted Wed May 27, 2009 11:36 AM

    Originally posted by: Emittim3@Sirius


    Like was said, the number of arguments limit is being exceeded in the shell. If you can't modify that, one of the tricks is to instead pipe the output of one command into another that executes on each line instead of attempting to execute on a list of arguments all in one command. So you could try piping the results of the find into a set of awk and xargs commands, or perform the operation in a shell loop instead of in the -exec portion of the find command.

    Example:

    find /home -name '*.core' -exec rm -f {} \;

    <blork!!! argument list too long!!!>

    could be re-written with:

    find /home -name '*.core' | xargs -l1 rm -f

    (should work, although I'm doing this from somewhat memory - but it should at least give you the idea.... if piping to xargs doesn't do it, you could perform in in a loop:)

    for x in `find /home -name '*.core'`
    do
    rm -f $x
    done
    #AIX-Forum


  • 9.  Re: why error "parameter list too long" when develope script for copy files

    Posted Thu June 25, 2009 12:59 AM

    Originally posted by: SystemAdmin


    (should work, although I'm doing this from somewhat memory - but it should at least give you the idea.... if piping to xargs doesn't do it, you could perform in in a loop:)

    for x in `find /home -name '*.core'`
    do

    actually that doesn't work, unfortunately, that will result in the same error with a large result set

    but this does (and this was tested with 1884 files):
    #count the number of files retrieved...
    ls $INPUT_DIR > input_dir.lst
    ACTUAL_TOTAL=`(awk 'BEGIN {x=0;} /.mp3/ {x=x+1} END {printf "%s",x}' input_dir.lst)`

    echo "Number of file retrieved = $ACTUAL_TOTAL"
    #AIX-Forum


  • 10.  Re: why error "parameter list too long" when develope script for copy files ?

    Posted Wed May 27, 2009 05:56 AM

    Originally posted by: SystemAdmin


    hmm not sure about this one

    Regards,
    Money Possum
    [url=http://makemoneyhomecourse.com/earn-money-from-home/]earn money from home[/url]
    #AIX-Forum


  • 11.  Re: why error "parameter list too long" when develope script for copy files ?

    Posted Sun September 30, 2012 10:18 AM

    Originally posted by: Markovin


    Long Path Tool helped me in this situation. http://PathTooDeep.com
    #AIX-Forum