shell遠程執行命令

1、先要配置免密登陸,查看上一篇免密傳輸內容

2、命令行執行少量命令:ssh ip "command1;command2"。例:ssh 172.1.1.1 "cd /home;ls"

3、腳本批量執行命令:

  #!/bin/bash

  ssh ip <<? remotessh

? ? ? ?cd /home

  ls

  remotessh

  注:第一條命令和結束命令需頂格寫,不然貌似要報錯,實踐得出。。。。

  例:

  #/bin/bash

  ssh ip <<remotessh

  cd /home

  pid=\$(ps -ef | grep tomcat | grep -v grep | awk {print\$2})

  kill -9 \$pid

  remotessh

  注:$字符需要用\轉義,不然識別不了,實踐得出。。。。。

4、遠程運行時,可能會出現找不到命令,比如說jar命令:

  原因:

  /etc/profile: 當用戶登錄時,該文件被執行.?
  /etc/bashrc: 當bash shell被打開時,該文件被執行.

  ssh作為non-login方式進入,當然就無法觸發/etc/profile的執行了。?
  所以應該設置到/etc/bashrc里面去.?

轉載于:https://www.cnblogs.com/heiboy/p/11288479.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391922.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391922.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391922.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Python調用C語言

Python中的ctypes模塊可能是Python調用C方法中最簡單的一種。ctypes模塊提供了和C語言兼容的數據類型和函數來加載dll文件&#xff0c;因此在調用時不需對源文件做任何的修改。也正是如此奠定了這種方法的簡單性。 示例如下 實現兩數求和的C代碼&#xff0c;保存為add.c //samp…

多重線性回歸 多元線性回歸_了解多元線性回歸

多重線性回歸 多元線性回歸Video Link影片連結 We have taken a look at Simple Linear Regression in Episode 4.1 where we had one variable x to predict y, but what if now we have multiple variables, not just x, but x1,x2, x3 … to predict y — how would we app…

tp703n怎么做無線打印服務器,TP-Link TL-WR703N無線路由器無線AP模式怎么設置

TP-Link TL-WR703N無線路由器配置簡單&#xff0c;不過對于沒有網絡基礎的用戶來說&#xff0c;完成路由器的安裝和無線AP模式的設置&#xff0c;仍然有一定的困難&#xff0c;本文學習啦小編主要介紹TP-Link TL-WR703N無線路由器無線AP模式的設置方法!TP-Link TL-WR703N無線路…

unity 克隆_使用Unity開發Portal游戲克隆

unity 克隆Learn game development principles by coding a Portal-like game using Unity and C#. The principles you learn in this lecture from Colton Ogden can apply to any programming language and any game.通過使用Unity和C&#xff03;編寫類似于Portal的游戲來學…

swift基礎學習(八)

####1.主要用到的知識點 CAGradientLayer 處理漸變色AVAudioPlayer 音頻播放Timer 定時器CABasicAnimation 動畫#####2.效果圖 ####3.代碼 import UIKit import AVFoundationclass ViewController: UIViewController, AVAudioPlayerDelegate {var gradientLayer: CAGradientLay…

pandas之groupby分組與pivot_table透視

一、groupby 類似excel的數據透視表&#xff0c;一般是按照行進行分組&#xff0c;使用方法如下。 df.groupby(byNone, axis0, levelNone, as_indexTrue, sortTrue, group_keysTrue,squeezeFalse, observedFalse, **kwargs) 分組得到的直接結果是一個DataFrameGroupBy對象。 df…

js能否打印服務器端文檔,js打印遠程服務器文件

js打印遠程服務器文件 內容精選換一換對于密碼鑒權方式創建的Windows 2012彈性云服務器&#xff0c;使用初始密碼以MSTSC方式登錄時&#xff0c;登錄失敗&#xff0c;系統顯示“第一次登錄之前&#xff0c;你必須更改密碼。請更新密碼&#xff0c;或者與系統管理員或技術支持聯…

spring—JdbcTemplate使用

JdbcTemplate基本使用 01-JdbcTemplate基本使用-概述(了解) JdbcTemplate是spring框架中提供的一個對象&#xff0c;是對原始繁瑣的Jdbc API對象的簡單封裝。spring框架為我們提供了很多的操作模板類。例如&#xff1a;操作關系型數據的JdbcTemplate和HibernateTemplate&…

vanilla_如何在Vanilla JavaScript中操作DOM

vanillaby carlos da costa通過卡洛斯達科斯塔 如何在Vanilla JavaScript中操作DOM (How to manipulate the DOM in Vanilla JavaScript) So you have learned variables, selection structures, and loops. Now it is time to learn about DOM manipulation and to start doi…

NOIP201202尋寶

題目 試題描述傳說很遙遠的藏寶樓頂層藏著誘人的寶藏。 小明歷盡千辛萬苦終于找到傳說中的這個藏寶樓&#xff0c;藏寶樓的門口豎著一個木板&#xff0c;上面寫有幾個大字&#xff1a;尋寶說明書。說明書的內容如下&#xff1a;藏寶樓共有N1層&#xff0c;最上面一層是頂層&…

修改UITextField中的placeholder的字體

修改字體顏色&#xff1a; [textField setValue:[UIColor redColor] forKeyPath:"_placeholderLabel.textColor"]; 復制代碼 修改字體大小&#xff1a; [textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:"_placeholderLabel.font"]; 復…

如何使用Python處理丟失的數據

The complete notebook and required datasets can be found in the git repo here完整的筆記本和所需的數據集可以在git repo中找到 Real-world data often has missing values.實際數據通常缺少值 。 Data can have missing values for a number of reasons such as observ…

MySQL—隔離級別

READ UNCOMMITED(讀未提交) 即讀取到了正在修改但是卻還沒有提交的數據&#xff0c;這就會造成數據讀取的錯誤。 READ COMMITED(提交讀/不可重復讀) 它與READ UNCOMMITED的區別在于&#xff0c;它規定讀取的時候讀到的數據只能是提交后的數據。 這個級別所帶來的問題就是不可…

做虛擬化服務器的配資一致嘛,服務器虛擬化技術在校園網管理中的應用探討.pdf...

第 卷 第 期 江 蘇 建 筑 職 業 技 術 學 院 學 報14 3 Vol.14 曧.3年 月 JOURNAL OF JIANGSU JIANZHU INSTITUTE2014 09 Se .2014p服務器虛擬化技術在校園網管理中的應用探討,汪小霞 江建( , )健雄職業技術學院 軟件與服務外包學院 江蘇 太倉 215411: , ,摘 要 高校校園網數據…

aws中部署防火墻_如何在AWS中設置自動部署

aws中部署防火墻by Harry Sauers哈里紹爾斯(Harry Sauers) 如何在AWS中設置自動部署 (How to set up automated deployment in AWS) 設置和配置服務器 (Provisioning and Configuring Servers) 介紹 (Introduction) In this tutorial, you’ll learn how to use Amazon’s AWS…

Runtime的應用

來自&#xff1a;http://www.imlifengfeng.com/blog/?p397 1、快速歸檔 (id)initWithCoder:(NSCoder *)aDecoder { if (self [super init]) { unsigned int outCount; Ivar * ivars class_copyIvarList([self class], &outCount); for (int i 0; i < outCount; i ) …

使用 VisualVM 進行性能分析及調優

https://www.ibm.com/developerworks/cn/java/j-lo-visualvm/轉載于:https://www.cnblogs.com/adolfmc/p/7238893.html

spring—事務控制

編程式事務控制相關對象 PlatformTransactionManager PlatformTransactionManager 接口是 spring 的事務管理器&#xff0c;它里面提供了我們常用的操作事務的方法。注意&#xff1a; PlatformTransactionManager 是接口類型&#xff0c;不同的 Dao 層技術則有不同的實現類 …

為什么印度盛產碼農_印度農產品價格的時間序列分析

為什么印度盛產碼農Agriculture is at the center of Indian economy and any major change in the sector leads to a multiplier effect on the entire economy. With around 17% contribution to the Gross Domestic Product (GDP), it provides employment to more than 50…

SAP NetWeaver

SAP的新一代企業級服務架構——NetWeaver    SAP NetWeaver是下一代基于服務的平臺&#xff0c;它將作為未來所有SAP應用程序的基礎。NetWeaver包含了一個門戶框架&#xff0c;商業智能和報表&#xff0c;商業流程管理&#xff08;BPM&#xff09;&#xff0c;自主數據管理&a…