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

Source: Internet
Author: User

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

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 root @ "$ IP":/tmp/ssh root @ $ {IP} <EOF # Face host, 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.