Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Require single command to start script in multiple servers

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-29-2012
mirwasim mirwasim is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 12 April 2015, 1:29 PM EDT
Posts: 107
Thanks: 8
Thanked 1 Time in 1 Post
Require single command to start script in multiple servers

I have 9 servers, on each server a script with common name is available.

I send a token file to all server from 1 particular server. so when a daemon job checks that token file is available then it triggers the script..

I want to know is there any command or script which I will run/execute on one server and it will trigger script on another server/servers.

Thanks in advance
Sponsored Links
    #2  
Old Unix and Linux 12-29-2012
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 27 August 2015, 4:00 PM EDT
Location: NM
Posts: 10,529
Thanks: 353
Thanked 880 Times in 818 Posts
Assuming you have ssh enabled, and ssh-keys from server0 distributed onto server1-server9:


Code:
# from your desktop or server0 (or server1 for that matter)

for sv in server1 server server3  # and so on
do
     ssh $sv '/path/to/script_that_starts_something.shl'
done

Sponsored Links
    #3  
Old Unix and Linux 12-29-2012
mirwasim mirwasim is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 12 April 2015, 1:29 PM EDT
Posts: 107
Thanks: 8
Thanked 1 Time in 1 Post
Hello.


Code:
#!/bin/sh
for sv in $1  # and so on
do
     ssh $sv '/export/home/pin/pin/bin/healthcheck_ONDB.ksh'
done

It did send command to server and script execute also but the functionality script does, it did do any of them..i killed that script.. it even didnt write the txt file also

---------- Post updated at 10:55 PM ---------- Previous update was at 10:42 PM ----------

And how to check ssh is enabled and ssh keys are distributed..

indeed script got triggered but it did not perform functionality.
and i killed it..

---------- Post updated at 11:00 PM ---------- Previous update was at 10:55 PM ----------

if u talking about public key, private key, then yes its on all hosts
    #4  
Old Unix and Linux 12-29-2012
spacebar's Unix or Linux Image
spacebar spacebar is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 2 June 2014, 3:23 PM EDT
Location: spaceBAR Central
Posts: 440
Thanks: 0
Thanked 71 Times in 70 Posts
If you log in to remote server via ssh and run the script from the command line, Does it work properly?

I'm pretty sure your ".profile" on the remote server(s) do not get sourced(i.e. executed) when running a script or command via ssh(non-interactive), For ksh or sh shell try this:

Code:
#!/bin/sh
for sv in $1  # and so on
do
  ssh $sv '. ~/.profile; /export/home/pin/pin/bin/healthcheck_ONDB.ksh'
done

Sponsored Links
    #5  
Old Unix and Linux 12-29-2012
mirwasim mirwasim is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 12 April 2015, 1:29 PM EDT
Posts: 107
Thanks: 8
Thanked 1 Time in 1 Post
script
Code:
pin@ssapp1025[wasim]$ cat test.sh
#!/bin/sh
for sv in $1  # and so on
do
     ssh $sv '(. $HOME/.profile;/export/home/pin/pin/bin/healthcheck_ONDB.ksh)'
done

Error

Code:
+ ssh ssapp1020 (. $HOME/.profile;/export/home/pin/pin/bin/healthcheck_ONDB.ksh)

WARNING: Access to this computer system is limited to authorised users only.
Unauthorised users may be subject to prosecution under the Crimes
Act or State legislation.

Please note, ALL CUSTOMER DETAILS are confidential and must not be
disclosed.


stty: : Invalid argument
logout

stty: : Invalid argument
ksh: MANPATH: parameter not set

in cron we set any job like this

Code:
00 23 * * 2 (. $HOME/.profile;/export/home/pin/pin/bin/Tomcat_restart.sh) > /dev/null 2>&1

Sponsored Links
    #6  
Old Unix and Linux 12-31-2012
mirwasim mirwasim is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 12 April 2015, 1:29 PM EDT
Posts: 107
Thanks: 8
Thanked 1 Time in 1 Post
I got rid of this error
Code:
stty: : Invalid argument

but

script
Code:
for sv in ssapp1023  # and so on
do
  ssh -qt $sv '. /export/home/pin/pin/.profile;/export/home/pin/pin/bin/healthcheck_ONDB/healthcheck.ksh'
done

Now below is result

Code:
+ ssh -qt ssapp1023 . /export/home/pin/pin/.profile;/export/home/pin/pin/bin/healthcheck_ONDB/healthcheck.ksh
ksh: MANPATH: parameter not set
logout

Please advice why this parameter not set error is coming
Sponsored Links
    #7  
Old Unix and Linux 12-31-2012
sathyaonnuix's Unix or Linux Image
sathyaonnuix sathyaonnuix is offline
Registered User
 
Join Date: Aug 2012
Last Activity: 26 June 2014, 12:23 PM EDT
Posts: 129
Thanks: 35
Thanked 14 Times in 13 Posts
I believe the keys are not setup yet.

In your remote machine, can you please check whether the current server name is added into the ~/.ssh/authorized_keys file ?
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to execute command to get info from multiple servers stunn3r Shell Programming and Scripting 4 10-19-2012 01:03 PM
Would you please give me some idea about single client and multiple servers sehang Programming 1 03-12-2011 09:31 PM
Automatic execution of commands in multiple servers using single script. vickramshetty HP-UX 4 11-17-2009 11:17 AM
Regarding accessing multiple servers using single public ip address navneet_2009 SuSE 5 07-29-2009 07:30 AM
ssh: require passphrase from some servers but not others Squeakygoose UNIX for Advanced & Expert Users 3 07-14-2009 08:30 PM



All times are GMT -4. The time now is 01:07 AM.