questions regarding executing remote scripts
Hi
Ok, so the plan is this: We have a central server for monitoring all kinds of stuff. One of the jobs I've been asked to get it to do is to analyse (albeit in a less than analytical manner) some log files and email the results back. I get that you can : Code:
ssh $SERVER 'bash -s' < codeyouwanttorun.sh Pseudo code follows: Code:
Read list of servers to check For example: can you ssh from server A onto server B and execute a piece of code that tells server B to ssh back to server A to run mailx? (or is that not only stupid, but reprehensible?) Thanks in advance! |
Everything you suggest sounds right. The only thing you might not
be aware of is that you don't need to transfer the data if you're using an ssh connection. The standard output from the remote server will be directed to your local host. So if you want to check multiple files and have the output go into separate files, you'll have to spawn a new ssh connection each time. For example: Code:
for Server in Server1 Server2 Server3; do |
Quote:
do something in Linux. I almost never say not to do something a certain way, because there may be a reason to select a more complex solution over a simple solution for a specific environment. So it's not stupid or reprehensible, it's just more complex than running the code on B in an ssh connection and using its output on A to then run mailx on A. If you're wondering why I like simple solutions, they are less likely to break and they are easier to troubleshoot. Not to mention that it makes life easier 6 months from now when you need to modify it and you really don't recall what you did in the first place! |
Thank you for at least concluding I'm rational, carltm. So I guess I am probably on the right track with this:
Code:
NAMES=( bloat bubbles callisto pandora lapetus tethys dactyl janus metis tad ganymede sponde deimos bab puck) Code:
#!/bin/sh Code:
#!/bin/sh
|
Well, we're a few weeks down the line now and not much has happened evolutionarily speaking. Now, however, I've run into a very odd thing. Whenever I run these scripts interactively all seems peachy and the servers do as expected, (i.e. a job is executed on the remote server that I need it to.
However, when this runs as a cron job, no output is returned from the remotely executed script, and for the life of me I cannnot figure out why. Before you ask me: - I'm using key-pair authentication and it works fine. - other cron jobs that call our remote servers seem to run fine but everything that they are being asked to achieve is all put on one line separated with pipes, and as good as I may be with pipes, I'm not sure that what I'm asking this job to do is up to being done as a single command string separated by piping! Your thoughts and ideas gratefully received as ever! |
All times are GMT -5. The time now is 12:00 PM. |