[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with tail -f that need to add to each line constant string a
From: |
dan12341234 |
Subject: |
Re: problem with tail -f that need to add to each line constant string at the beginning of each line |
Date: |
Tue, 1 Nov 2011 00:42:30 -0700 (PDT) |
Hi
what if i want to put this commands on a script
ssh -n server1 'tail -f /var/log/syslog | sed --unbuffered
"s/^/$(hostname): /"' >>syslog.tail.out &
ssh -n server2 'tail -f /var/log/syslog | sed --unbuffered
"s/^/$(hostname): /"' >>syslog.tail.out &
can you advise
Thanks a lot
Dan
Bob Proulx wrote:
>
> dan sas wrote:
>> what about if i want to run both commands simultaneous and send the
>> output to a file how can i do that
>
> This is getting further off topic for the bug bash mailing list. It
> really isn't too much about bash but just general help with how things
> work. A better place to ask these types of questions would be the
> help-gnu-utils@gnu.org mailing list. If you have more questions in
> the future let's please have the discussion there.
>
> You could put the commands in the background. To put commands in the
> background use the '&' character at the end of the command line.
>
> If a command is terminated by the control operator &, the shell
> exe-
> cutes the command in the background in a subshell. The shell does
> not
> wait for the command to finish, and the return status is 0.
> Commands
> separated by a ; are executed sequentially; the shell waits for
> each
> command to terminate in turn. The return status is the exit
> status of
> the last command executed.
>
> And also redirect the output to a file.
>
> ssh -n server1 'tail -f /var/log/syslog | sed --unbuffered
> "s/^/$(hostname): /"' >>syslog.tail.out &
> ssh -n server2 'tail -f /var/log/syslog | sed --unbuffered
> "s/^/$(hostname): /"' >>syslog.tail.out &
>
> By this point it looks very much like you are trying to re-invent the
> remote logging feature of a syslogd. Because I now expect a new
> question about how to start and restart this connection automatically.
> (Am I right? :-) Instead please investigate using one of the syslog
> programs that does exactly that already. See for example 'rsyslogd'
> which supports remote logging.
>
> Good luck!
> Bob
>
>
>
--
View this message in context:
http://old.nabble.com/problem-with-tail--f-that-need-to-add-to-each-line-constant-string-at-the-beginning-of-each-line-tp32742979p32757229.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: problem with tail -f that need to add to each line constant string at the beginning of each line,
dan12341234 <=