Shell script execution on multiple servers

c0mrade

Is it possible to run one part of the ksh/sh script on one server then ssh to another server and continue with the rest of the script? Or is there a work-around?

I have a user with which I don't have to authenticate each time I access a server, so I can hop from one server to another without any keyboard interaction.

I've already tried this, trying to separate some logic into another script then :

MYSCRIPT="nohup ksh myscript.ksh > mylog.log &"
ssh servername ${MYSCRIPT}

I tried this but it doesn't seem to execute this script on another server.

The whole code above is part of a for loop; I execute the same script for a list of servers.

For testing purposes, the list has two servers; for some weird and twisted reason, only the last (or second) server script works as I expect.

All servers can see myscript.ksh -- it is visible and executable to all of them.

Kevin M

It sounds like you want to run a sequence of commands on another server without having to log in multiple times. To accomplish this, you could do:

local_command sequence
ssh remote-server << End-Of-File
        remote_command 1
        remote_command 2
        remote_command 3
End-Of-File

This would run remote_command 1, and when it finishes, run remote_command 2, then remote_command 3 all on the remote server

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Synchronized script execution across multiple servers

Shell script to run Linux command on multiple servers command by command

shell script to run commands over SSH on multiple remote servers

Play and task execution with multiple groups and servers with ansible

Rsync backup script for multiple servers

How can I create a MongoDB cluster using multiple/three nodes/servers/machines using a single shell script?

Having a shell script default to execution

How to execute shell script on two servers

how to run my selenium script on multiple servers at the same time so that i would saved one by one execution time?

Running shell commands remotely on multiple servers?

script to check if I can access multiple servers

Pinging to multiple servers via windows batch script

Monitoring multiple Linux Systems or Servers Script

shell script with multiple variables

Shell script: if multiple conditions

Multiple shell script workers

Invoke a shell script execution using nagios

Assigning shell script execution result to variable

Use shell variables while execution of the script

How to debug shell process execution by php script?

Use echo options when execution shell script

Delay for every command execution in shell script

How do I identify shell script execution vs dot execution

How to differentiate servers in PHP script executed via shell?

script hangs due to `exec` on AiX servers with ksh shell

In my bash loop over a list of some servers the script exits after execution a perl script with ssh

shell script run multiple files

A expect script with multiple shell statements

Shell script to delete multiple files