The requirements background is:
A business, with 3 servers (A,B,C) Doing load balancing, because the scale is too small to use a professional automated maintenance tool at this time. When there is a new requirement, the development colleague changes the code to upload the change to one of the server A. But the other 2 servers also need to make the same changes.
Write a shell script that synchronizes the change code on the a server to B and C.
Where you need to consider directories that do not need to be synchronized (if you have TMP, upload, logs, caches)
#!/bin/bashecho "The script will synchronize the/data/wwwroot/www.aaa.com directory on the A machine to the b,c machine"; Read-p "Do you want to continue? (y|n) "RS () {rsync-azp--exclude logs--exclude upload--exclude caches--exclude tmp www.aaa.com/$1:/data /wwwroot/www.aaa.com/}if [$REPLY = = ' y '-o $REPLY = = ' Y ']then echo "About to sync ..." Sleep 2 cd/data/wwwroot/rs B Machine IP rs C machine IP echo "is completed synchronously. "Elif [$REPLY = = ' n '-o $REPLY = = ' n ']then exit 1else echo" Please enter the letter Y or n "fi
This article is from the It Dick thread blog, so be sure to keep this source http://68686789.blog.51cto.com/10438688/1980112
Shell exercises-Bulk Sync code