Connect the SSH client to the host and run the script in the nohup background.

Source: Internet
Author: User

The following script is implemented: first copy the script from the local host to the remote host, and then connect to the remote host using SSH to execute the copied script (because the script needs to be executed for a long time, it should be executed in the background ), this script is only used for memo. If you have any questions, please kindly advise!

#! /Bin/bashcd/tmpi1_1#ip.txt Save the host list. The third column is IP, and the second column is host name, the first column lists the host address cat ip.txt | while read linedo IP = 'echo $ Line | awk' {print $3} ''addr = 'echo $ Line | awk' {print $1} ''echo "I = $ I $ ADDR IP = $ IP" SCP-o "stricthostkeychecking no"/root/TT/greplog. sh [email protected] "$ IP":/tmp/ssh [email protected] $ {IP} <EOF # host on the face, execute multiple commands, the premise is to configure the key to log on to chmod A + x/tmp/greplog. sh nohup/tmp/greplog. sh> myout. file 2> & 1 & # Put it in the background and execute exiteof I = 'expr $ I + 1' doneexit 0


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.