Bash Xargs Sleep (Multiple Command Line Arguments) -
ok have following script updates route43 dns entries. unfortunately there limit number of calls per second can make need make final xargs command sleep second between each iteration.
i've tried couple of things ' {../cli53 blah; sleep 10; } ' , cant seem work. have suggestions please:
#!/bin/bash set root='dirname $0' ec2-describe-instances -o ******* -w ******* --region eu-west-1 | perl -ne '/^instance\s+(i-\s+).*?(\s+\.amazonaws\.com)/ , { $dns = $2; print "$1 $dns\n" }; /^tag.+\sname\s+(\s+)/ , print "$1 $dns\n"' | perl -ane 'print "$f[0] cname $f[1] --replace\n"' | grep -v 'i-' | xargs --verbose -n 4 /usr/local/bin/cli53 rrcreate -x 5 contoso.com edit: etan answer. here solution else needs it:
i had include -i %variable% switch xargs statement aswel make sure feed in passed parameters cli53 looks working nicely now.
#!/bin/bash set root='dirname $0' ec2-describe-instances -o ******* -w ******* --region eu-west-1 | perl -ne '/^instance\s+(i-\s+).*?(\s+\.amazonaws\.com)/ , { $dns = $2; print "$1 $dns\n" }; /^tag.+\sname\s+(\s+)/ , print "$1 $dns\n"' | perl -ane 'print "$f[0] cname $f[1] --replace\n"' | grep -v '^i-' | xargs --verbose -n 4 -i myvar /bin/sh -c '{ /usr/local/bin/cli53 rrcreate -x 5 contoso.com 'myvar'; sleep 1; printf "\n\n"; }'
the simplest solution put cli53 , sleep calls in script , use xargs execute script.
if don't want should able trying this:
... | xargs ... /bin/sh -c '{ /usr/local/bin/cli53 ... "$@"; sleep 10; }' -
Comments
Post a Comment