Re: Redirection output for a program in background



On Mar 10, 10:21 am, Tom Newton <t...@xxxxxxxxxxxxxx> wrote:
On 2008-03-10, Mad Ant <anton.har...@xxxxxxxxx> wrote:



Hello all.

I have a little question concerning the redirections of text. I know
it's possible to redirect the output when starting the program from
the command line, with pipes and greater-thans and so on.
However, I have a program that starts at boot and runs as a daemon,
which also prints text to standard output.
But since it's started at boot, I have no access to the output that's
being printed.

The question I want to ask is this : is it possible, while a program
is running, to redirect the standard output on the fly to a terminal
to see the output text being produced ?
This would be especially useful for me, since I have to sometimes
administer machines via SSH.

I know it's possible to look at the file /var/log/messages, but since
it receives all the text, I don't want to have to meander through the
files to find the text being printed from my program.

Many thanks for any help that can be provided.

Mad Ant

You could have cron run a script that greps out the lines from
/var/log/messages that you want, every N minutes/seconds, putting
them in a seperate file, then have a function that runs tail -f
on that new file with a couple of keystrokes:

cv () { tail -f /tmp/special; }

Tom

--
calhobbit (at) | The Truth will set you free:
gmail [DOT] com | http://www.sethcenter.com

Thanks for the quick response.
I did think of a similar solution, ie writing a script (shell or Perl)
that reads the message file and filters the lines, but this will
always leave me 'behind' in the sense that I won't be able to see
results on the fly.
Is there any way to do this ?

Mad Ant
.



Relevant Pages

  • debugging init script in FC4
    ... I tried loads of alternatives and eventually found if I renamed the script ... I then tried configuring the script to start at boot, ... init script to redirect to a file. ...
    (comp.os.linux.misc)
  • Re: Redirection output for a program in background
    ... with pipes and greater-thans and so on. ... But since it's started at boot, I have no access to the output that's ... to redirect the standard output on the fly to a terminal ...
    (comp.os.linux.misc)
  • Re: redirecting standard output
    ... provided you get a standard output). ... With each run of your script, the log file ... I think he is asking how the shell script itself can redirect its own ... NOt hoow you can redirect its standard output to a file. ...
    (comp.os.linux.misc)
  • Re: redirecting standard output
    ... provided you get a standard output). ... With each run of your script, the log file ... I think he is asking how the shell script itself can redirect its own ... NOt hoow you can redirect its standard output to a file. ...
    (comp.os.linux.misc)
  • Re: Redirection output for a program in background
    ... the command line, with pipes and greater-thans and so on. ... But since it's started at boot, I have no access to the output that's ... to redirect the standard output on the fly to a terminal ...
    (comp.os.linux.misc)