您好,登錄后才能下訂單哦!
#!/bin/bash ######################################################################### # File Name : rsync_nobody.sh # Author : gongy # Mail : 458026734@qq.com # Created time : 2016-06-29 09:58:53 # Last modified : 2016-06-29 09:58:53 # Description : rsync nobodyfile to remote machine. ######################################################################### #Loading system function library. source /etc/init.d/functions set -e #defined variable. DATE=`date +%Y%m%d` TIME=`date '+%F %H:%M:%S'` MYSQL_USER="" MYSQL_PASSWD="" MYSQL_ADDRESS="" EXEC_LOG="/app/control_crontab/log/exec_$DATE.log" DATA_LOG="/app/control_crontab/log/${IP}_data_$DATE.log" SOURCE_FILE="/app/control_crontab/cron/nobody/" DIST_FILE="/var/spool/cron" #get ip list. ip=( `mysql -uroot -e "use db_devops;select IP from tbl_all_ip"|sed '1d'` ) function judge(){ if [ $? -eq 0 ];then action "$TIME-${ip[$i]}-rsync nobody file" /bin/true else action "$TIME-${ip[$i]}-rsync nobody file" /bin/false #MSG="${ip[$i]}更新nobody失敗" #curl "http://alarm.51.com/alarm/index.php?type=1&gid=99&msg=${MSG}" &>/dev/null fi } function rsync_all(){ #rsync all nobody file. for ((i=0;i<${#ip[*]};i++)) do #rsync同步nobody到RMOTE主機,更新文件. rsync -az ${SOURCE_FILE}/nobody-${ip[$i]} ${ip[$i]}:${DIST_FILE}/nobody &> /dev/null judge done } #echo "===========================================================================" >> ${EXEC_LOG} function rsync_more(){ #IP=`cat ip_file` for IP in `cat ip_file` do rsync -az ${SOURCE_FILE}/nobody-$IP $IP:${DIST_FILE}/nobody &> /dev/null result done } function result(){ if [ $? == 0 ];then echo "$TIME-$IP-rsync nobody file....................................................[OK]" else echo "$TIME-$IP-rsync nobody file....................................................[FAILED]" fi sleep 1 } read -p "Please enter your chose all/one:" input case $input in "all") rsync_all ;; "one") read -p "Please enter the file:" ip_file rsync_more ;; *) exit ;; esac
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。