When server B (172.17.166.11) is powered on or restarted, it will automatically pull all the files in the specified directory on server A (172.17.166.10) 1. Create mutual trust between server B and server A
2. On Server B Create the following directory structure [root@w-11 home]# tree shell shell ├── logs ----directory └── pull_170.sh ----script The script is as follows: #!/bin/bash #pull_ #author:whz #date:20200805 #The non-existent variable terminates the script execution set -o nounset # Execution error terminates script execution set -o errexit # define restricted path PATH="/bin:/usr/bin:/sbin:/usr/sbin" # adirname - return absolute dirname of a given file adirname() { odir=`pwd`; cd `dirname $1`; pwd; cd "${odir}"; } MYNAM=`basename "$0"` MYDIR=`adirname "$0"` MYLOG_PATH="${MYDIR}/logs" MYLOG="${MYLOG_PATH}/${MYNAM}_`date +%F`.log" echo "`which rsync` -avtW --progress --delete [email protected]:/home/iis/ /home/iis/" >> ${MYLOG} `which rsync` -avtW --progress --delete [email protected]:/home/iis/ /home/iis/ >> ${MYLOG} exit 0 3. Crontab plan on server B
That’s it, done. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Summary of knowledge points about covering index in MySQL
This article example shares the specific code of ...
Demand scenario: The existing PXC environment has...
HTML web page list tag learning tutorial. In HTML ...
There is no solution for Chinese input method und...
introduction Looking back four years ago, when I ...
Another important aspect of separating structure ...
Object's hasOwnProperty() method returns a Bo...
Nginx Installation CentOS 6.x yum does not have n...
Table of contents 1. Preparation 2. Decompression...
The specific method of installing CentOS 7.0 on V...
If we want to make a carousel, we must first unde...
Table of contents 1. Background running jobs 2. U...
In fact, many companies have functions similar to...
location expression type ~ indicates to perform a...
In Docker's design, a container runs only one...