Running a script on multiple machines


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Running a script on multiple machines
# 1  
Old 06-17-2003
Data Running a script on multiple machines

To clear the web cache on my web server, I run this command:

find $APACHE_HOME/cache/plsql/plsql -type d -name "[0-9]*" -exec rm -R {} \;

To clear the cache on all the web servers(we have 4), I log on to any one machine, clear its cache, ssh to another machine, clear cache etc;

Is there any way to write a script so that this operation can be performed in one script ?

In other words, the script automatically ssh's into the 2nd server, clears the cache and then logs on to 3rd server and so on.

The ssh is over a trusted network and I am using the same account on each of these boxes so I am not prompted for password when going from one machine to another.

I tried to write such a script but what happens is although it logs into the other machine, I see a prompt for the other machine and when I exit it, I am back to the original machine. The script then runs on the original machine.

The shell is ksh and the OS is Solaris 2.8.

Thanx
# 2  
Old 06-17-2003
Looks lke u might have set some environtal variables...
# 3  
Old 06-17-2003
If you wanted to use a script, then you just need to put the command in the script in the format of the ssh command -

ssh [-l login_name] hostname | user@hostname [command]

#!/bin/ksh
#
ssh myuser@myhost find $APACHE_HOME/cache/plsql/plsql -type d -name "[0-9]*" -exec rm -R {} \;
#
exit

You may need some type of quotes for that line.
# 4  
Old 06-17-2003
Why not just install a cron job on each web server to clear the cache?
# 5  
Old 06-17-2003
Hi Perderabo,

The web cache is cleared only on specific instances like when it is brought out of rotation or when we apply a patch to our database or a new build etc.

Since I do not have any control over these times, I cannot put this in cron.

RTM,
I will try your script and let you know.

Thanx
# 6  
Old 06-18-2003
python should be able to do what you want.

it has the ability to logonto remote machines and execute the rest of teh script.
# 7  
Old 06-24-2003
can someone give me a perl script to do that please??? or a php one?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script running multiple commands at once

Hi All, I have put a perl script together to go and collect some information from multiple nodes/endpoints. The script works absolutly fine however I want to make it quicker. You will see in the below that my script calls an expect script called ssh_run_cmd2.exp followed by the IP of... (7 Replies)
Discussion started by: mutley2202
7 Replies

2. Shell Programming and Scripting

Shell Script to find out if a process is running on any all machines

Hi All, I have been a guest visitor from a long time and this forum is wonderful. I finally am a member of this forum too, so i am here stuck with a shell script that i was trying to write My requirement is that i should be able to create a shell script which will check if a process is running on... (3 Replies)
Discussion started by: Rex0226
3 Replies

3. UNIX for Dummies Questions & Answers

Running commands on remote machines

so i want to monitor a variety of things on hundreds of servers. the old process was to have an agent running on each one of these servers. but now i'm looking to see if its possible to have agentless monitoring. the only other straight forward option other than having an agent on the hosts, is... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. Shell Programming and Scripting

Running a script on multiple remote hosts at once

I have a script on about 15 hosts that I need to run for each host whenever I want (not crontab). Problem is, this script takes 5-10 mins to run for each host. Is there a way I can run the script in parallel for all the hosts instead of 1 at a time? Also, I'm remotely running the script on the... (3 Replies)
Discussion started by: mrskittles99
3 Replies

5. UNIX for Dummies Questions & Answers

running script in multiple locations

Hey guys I have written a bash script that compares two directories and displays the files that are different in the directories. Now my problem is the script only runs in my home directory. What do I have to do so it will run in other directories. Thanks if anyone can help. Duplicate post.... (0 Replies)
Discussion started by: Joey12
0 Replies

6. UNIX for Advanced & Expert Users

stagger ssh command to multiple machines

Good day, I am extracting information from Apache log files from 41 servers. Every day I have 7 cronjobs scheduled to do this for me and it works beautifully :D... only problem is that it takes about 6-9 hours to run through, as the script runs about 6 ssh commands for each box then goes to the... (3 Replies)
Discussion started by: msullivan
3 Replies

7. Shell Programming and Scripting

Running same script multiple times concurrently...

Hi, I was hoping someone would be able to help me out. I've got a Python script that I need to run 60 times concurrently (with the number added as an argument each time) via nightly cron. I figured that this would work: 30 1 * * * for i in $(seq 0 59); do $i \&; done However, it seems to... (4 Replies)
Discussion started by: ckhowe
4 Replies

8. AIX

Printing problem in AIX machines running SAP

Hi all, We have a intermittent problem with printing from SAP running on AIX5.2 . Version of Sap is 4.6b. When a print is fired from SAP, the spool is created fine and then transferred to the host spool system (in this case the AIX Print queue). The problem seems to be happening when AIX... (3 Replies)
Discussion started by: pauldavi26
3 Replies

9. Shell Programming and Scripting

running multiple rsh command in a script

hi scripting experts, juz wondering if it's possible to have multiple rsh command in a single script? :confused: ie: rsh -l <username> "<command>" rsh -l <username> "<command>" thanks. regards, wee :) (0 Replies)
Discussion started by: lweegp
0 Replies
Login or Register to Ask a Question