Require single command to start script in multiple servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Require single command to start script in multiple servers
# 1  
Old 12-29-2012
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
# 2  
Old 12-29-2012
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

# 3  
Old 12-29-2012
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 12-29-2012
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

# 5  
Old 12-29-2012
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

# 6  
Old 12-31-2012
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
# 7  
Old 12-31-2012
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 ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run simple single command on multiple Linux servers?

Hi All, How can i run a single command on multiple servers with or without giving credentials. I have a file(servers.txt) which has got list of servers and i want to run a command lsb_release -dr on all these servers and get output of those servers against each server. I tried below code... (9 Replies)
Discussion started by: darling
9 Replies

2. Shell Programming and Scripting

Logging in to multiple Linux servers and running the command.

Hi, I am trying to write a script to run a command on multiple linux based servers and get the o/p. I am using ssh to login. It is a celerra box and EMC NAS product. I am able login but i am not able to run nas command nas_pool -size -all the NAS server. I am getting the following error. ... (2 Replies)
Discussion started by: jpkumar10
2 Replies

3. Shell Programming and Scripting

Script to execute command to get info from multiple servers

Hi, I want to collect info from a no. of servers whether there grub.conf contain "elevator" parameter or not. What I want is sudo cat /etc/grub.conf | grep -q "elevator=noop"; echo $? If output is "0", I want name of that host in a file called "present" if its not "0", I want that... (4 Replies)
Discussion started by: stunn3r
4 Replies

4. Programming

Would you please give me some idea about single client and multiple servers

Hi, I have a program which needs to connect multiple servers at the same time. The program has to collect data from each of servers and then make a decision regarding to the data received. There are several requirements. 1. Server (s) may shutdown anytime without any ack (e.g.power... (1 Reply)
Discussion started by: sehang
1 Replies

5. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

6. HP-UX

Automatic execution of commands in multiple servers using single script.

Hi, I've to do a simple job many times whenever it has been asked, just i've to log in to all of fourtien HP servers and i've to execute ps -fu user > temp cat temp|sendmail "xyz@z.com" commands to send the statics of all of 14 servers over the mail to particular user id.. Though logging... (4 Replies)
Discussion started by: vickramshetty
4 Replies

7. SuSE

Regarding accessing multiple servers using single public ip address

Hello, Currently we are having different linux servers (for example: let's assume audio server, video server and text server) to handle requests from outside users. Suppose the outside users in different LAN (Local Area Network), other than the servers. For example user is in 20 series LAN and... (5 Replies)
Discussion started by: navneet_2009
5 Replies

8. UNIX for Advanced & Expert Users

ssh: require passphrase from some servers but not others

We have a number of linux clusters running Oracle. The clusters require that all member nodes have promptless/passwordless login through ssh (ie. the keys were created with null passphrases). We also have a management server that is not a member of any cluster but routinely connects to nodes of all... (3 Replies)
Discussion started by: Squeakygoose
3 Replies

9. Shell Programming and Scripting

Shell/perl script to connect to different servers in single login in teradata

Hi, I want to write a shell script to compare two tables in teradata.these tables are present on different servers. I want to connect to both servers in single login in order to fetch and compare the data in one go. Thanks (1 Reply)
Discussion started by: monika
1 Replies

10. UNIX for Dummies Questions & Answers

How to run multiple command in single command?

Dear Unix Guru, I have several directories as below /home/user/ dir1 dir2 dir3 Each directory has different size. I want to print each directory size (Solaris command du -hs .) Can you please guide me how to achieve this? Thanks Bala (2 Replies)
Discussion started by: baluchen
2 Replies
Login or Register to Ask a Question