簡體   English   中英

如何通過Shell腳本在遠程服務器上連接和運行Shell腳本

[英]How to connect and run shell script on remote server, via shell script

我幾乎不了解Shell腳本或終端命令。

想要實現:

制作一個Shell腳本,該腳本連接到遠程服務器,並在連接到該服務器之后,在該服務器上運行一些命令。

可能嗎?

我已嘗試使用谷歌搜索,但未找到任何東西,我正在尋找。

您可以使用ssh(安全外殼程序)執行此操作,可以參考此問題以獲取答案如何使用SSH在遠程計算機上運行外殼程序腳本?

/tmp/sh.sh  is shell script on remote server.

#!/bin/bash
ssh "root@server-ip" 'sh -c "( (nohup /tmp/sh.sh) )"'    

#use following for suppressing the output from remote server script.
ssh "root@server-ip" 'sh -c "( (nohup /tmp/sh.sh &>/dev/null ) & )"'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM