Synchronization script, in the 5th step to splice the host name of your own configuration
1#!/bin/Bash2#1gets the number of input parameters, if there are no parameters, exit directly3Pcount=$#4 if((pcount==0)); Then5 echo no args;6 exit;7 fi8 9#2Get file nameTenp1=$1 OneFname=$ (basename $p 1) AEcho fname=$fname - -#3get parent directory to absolute Path thepdir=$ (CD-P $ (dirname $p 1); pwd) -Echo pdir=$pdir - -#4get the current user name +User=$ (WhoAmI) - +#5Loops A for((host=3; host<5; host++)); Do at#echo $pdir/$fname [email protected]${xx} $host: $pdir -Echo---------------Hadoop00$host---------------- -RSYNC-RVL $pdir/$fname [email protected] $host: $pdir -Done
Command Script (note to modify the host name of the stitching)
1#!/bin/Bash2Pcount=$#3 if((pcount==0) ); Then4 echo no args;5 exit;6 fi7 8#echo-------------localhost----------9 [email protected]Ten for((host=3; host<=4; host++)); Do Oneecho----------Hadoop00$host--------- A SSH hadoop00$host [email protected] -Done
Save the script under/usr/local/bin and you can perform the global scope.
Linux distribution synchronization scripts and distribution command scripts