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