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

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

Multiple shell script workers

Delay for every command execution in shell script

script to check if I can access multiple servers

Define execution order for same script on multiple gameobjects

shell script run multiple files

Shell script: if multiple conditions

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

How do I identify shell script execution vs dot execution

Synchronized script execution across multiple servers

Running shell commands remotely on multiple servers?

How to execute shell script on two servers

How to differentiate servers in PHP script executed via shell?

Shell script to delete multiple files

Rsync backup script for multiple servers

How to debug shell process execution by php script?

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

Invoke a shell script execution using nagios

Having a shell script default to execution

tmux - split panes and ssh to multiple servers via script

Assigning shell script execution result to variable

A expect script with multiple shell statements

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

Monitoring multiple Linux Systems or Servers Script

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

Pinging to multiple servers via windows batch script

Play and task execution with multiple groups and servers with ansible

shell script to run commands over SSH on multiple remote servers

Use shell variables while execution of the script

TOP Ranking

HotTag

Archive