SSH Main parameter description
-L Specify Login user
-P Set Port number
-F run in the background, and recommended with the-n parameter
-n redirects standard input to/dev/null to prevent reading standard input
-N Do not execute remote command, only port forwarding
-Q Quiet mode, ignoring all dialogs and error hints
-T disabling pseudo-terminal configuration
# !/bin/sh host_list="host1 host2 host3 host4"ssh_port=2202for in $HOST _listdo "executing in $loop: "" $"
#ssh-F-P $SSH _port $loop "$" &
Echodone
Call Tar zxvf/root/pat.tar.gz-c/home
Invoking a remote script locally
$ ssh-l Oracle R7 '/tmp/b.sh &'
Note the following points:
& indicates the background execution, also can not add;
Script to have execute permission;
If a file is used in remote script b.sh, the file must be written to the full path, otherwise the default is the home directory of the specified user, not the current directory.
Simulating concurrency with pipelines
#!/usr/bin/ksh#SCRIPT:ptest.sh#author:ray001#date:2008/10/03#rev:2.0#For STUDY##PURPOSE:#enables process concurrency, improves execution efficiency, and records each execution failure of the child process information#define the number of concurrent processesParallel=3#To define a temporary pipe file nametmpfile=$.fifo#define export Profile full path namecmd_cfg= $HOME/cfg/ptest.cfg#defining failed Identity filesfailure_flag=Failure.log####################### function Definition #########################kill child process at breakfunction Trap_exit{kill-90}#General execution FunctionsExec_cmd () {#here is the actual command that needs to be executed, in this case using sleep as an exampleSleep ${1} if[ $? -NE 0] then echo"Command execution failed" return1Fi}trap'trap_exit; Exit 2'1 2 3 15#Cleanup failed identity fileRM-F ${failure_flag}#create a corresponding number of placeholders for concurrent processesMkfifo $TMPFILEexec4<>$TMPFILE RM-F $TMPFILE {count=$PARALLEL while[$count-GT 0] do echo let Count= $count-1Done }>&4#get each task in order from the task list seq whileread SEC do read<&4(Exec_cmd ${sec}|| Echo ${sec}>>${failure_flag}; echo >&4) & Done<$CMD _cfgwaitexec4>&-#determine if all succeeds after the concurrent process finishesif[ -F ${failure_flag}]then exit1ElseExit 0fi
Shell Remote Execution command