Created
April 2, 2013 00:53
-
-
Save JohnKim/5289100 to your computer and use it in GitHub Desktop.
여러대의 서버에 같은 쉘명령을 한번에 실행하기 (from http://www.powerbox.pe.kr/351)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### cmd.sh | |
#!/bin/sh | |
HOSTLIST=hostlist.dat | |
if [ ! -n "$1" ] | |
then | |
echo "usage: $0 \"command arg1 arg2 ... \"" | |
exit 1 | |
fi | |
for i in `cat ~/$HOSTLIST` | |
do | |
echo $i "$*" | |
ssh $i "$*" | |
done | |
### hostlist.dat | |
ip또는 hostname | |
ip또는 hostname | |
ip또는 hostname | |
### mcp.sh | |
#!/bin/sh | |
HOSTLIST=~/hostlist.dat | |
if [ ! -n "$1" ] | |
then | |
echo "usage: $0 \"copy-file-name\"" | |
exit 1 | |
fi | |
for i in `cat $HOSTLIST` | |
do | |
echo $i "$*" | |
scp $1 $i:$1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment