bug-bash
[Top][All Lists]
Advanced

[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: Bob Proulx
Subject: Re: problem with tail -f that need to add to each line constant string at the beginning of each line
Date: Sun, 30 Oct 2011 11:52:47 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

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
address@hidden 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]