本地檔案與伺服器檔案同步shell指令碼,

來源:互聯網
上載者:User

本地檔案與伺服器檔案同步shell指令碼,

為何建立此指令碼是因為方便項目的布署,不需要手動地去同步不同的項目,而只需要簡單的執行shell指令碼,輸入項目名就能發布到服器上。

1、shell檔案代碼

#!/bin/shread -t 30 -p "請輸入項目名:" nameecho -e "\n"echo "項目名為:$name" case $name in         cn)           rsync -r ~/project1 root@192.168.18.2:/project1 --exclude="test.css" --progress         ;;         cnb2b)           rsync -r ~/project2 root@192.168.18.2:/web/project2 --exclude="node_modules" --progress         ;;          *)           echo "Ignorant"         ;; esac  echo "同步完成"

 2、關鍵字解釋:

    name表示要同步的檔案名稱 

    --exculde="node_modules"表示過濾的檔案夾

    --progress 顯示檔案同步進程

  

 3、檔案建立並儲存

  將檔案儲存為name.sh

  使用. name.sh執行檔案

 

 4、具體進程;

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.