Linux shell Remote execution command __linux

Source: Internet
Author: User

Often to deploy multiple servers above the application, if a machine's login too cumbersome.

All just think about writing a script to deploy different servers

Prerequisites:

Configuring SSH Login Free

If not, please join me in another article http://blog.csdn.net/chenpy/article/details/30281515



(1) The command line executes the login and executes the command on the target server [Java] view plain copy ssh user@remotenode "cd/home;" LS "Basically can complete the commonly used for remote node management, a few attention points:
Double quotes that must be there. Without double quotes, the second LS command performs a semicolon locally, separated by a semicolon between two commands

(2) The way the script

This is officially the way I want to execute the batch command on the target server. [Java] view plain copy #!/bin/bash ssh root@192.168.0.23 << remotessh killall-9 java Cd/data/apa Che-tomcat-7.0.53/webapps/exit Remotessh

Remote execution of content between "<< remotessh" to "remotessh", the operation on the remote machine is located in it, attention to the point:<< remotessh,ssh until the end of the content of the REMOTESSH, Remotessh can be arbitrarily modified into other forms. Before ending, add exit to exit the remote node

If you do not want the log file to appear on this computer, you can modify the configuration

[HTML] view plain copy ssh root@192.168.0.23 >/dev/null 2>&1 << remotessh

OK, that's it.

Reference Document: Http://www.cnblogs.com/ilfmonday/p/ShellRemote.html


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.