Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to fetch logs from diffrent servers using one command?

For example, suppose I want to fetch logs for same id in different servers. I have to go to each server and search for logs.

Is there any way to do it one go?

share|improve this question

closed as not a real question by Gilles, Renan, n0pe, jasonwryan, Ulrich Dangel Mar 19 '13 at 0:04

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

What logs? What ID? – jordanm Mar 18 '13 at 15:08
Why do you need to do it in a single command? Isn't scp foo:/var/log/messages . && scp bar:/var/log/messages . enough? – l0b0 Mar 18 '13 at 15:24

You could do it with a for loop in bash.

for SERVER in foo bar
mkdir -p $SERVER
scp $SERVER:/var/log/messages $SERVER/

Replace foo and bar with the names of your servers.

share|improve this answer