Re: Confused by unexpected redirection behavior when using the watch command
- From: swordsaintzero@xxxxxxxxx
- Date: Thu, 9 Oct 2008 09:23:19 -0700 (PDT)
On Oct 9, 11:17 am, Icarus Sparry <use...@xxxxxxxxxxxxxxxxx> wrote:
On Thu, 09 Oct 2008 08:33:09 -0700, swordsaintzero wrote:
This is in GNU bash, version 2.05b.0(1)-release .
Using the watch command to update (something along the lines of)
watch "lsof -i | grep -i estab" >> watch.log
Doesn't give me the expected behavior I tried &>> and still don't get
the expected output.
What I am expecting is each time watch updates there is new data on the
screen to write out, and this would be appended to the file. I know it's
probably something simple but after a few hours and a lot of googling
still no love.
Also I am aware that I could use a loop rather than watch, but darn it I
really want to know what watch itself isn't doing what I asked is it
something to do with the way that watch prints to screen? I can pipe
it's output to grep so I am surprised I can't simply pipe it to a text
file.
Thanks in advance for any help.
Which "watch" program?
Are you sure that this is not just a buffering issue, i.e. so few new
connections are being established that the output is not changing enough
for the output bffer (typically 4k) to need to be flushed?
If you have "unbuffer" or "pty" on your system you could try running the
command under that, or run the command without the redirection inside
"screen" and let screen do the logging.
I wasn't even aware that there was a size limit needed to flush buffer
< so no I am not sure if it is a buffering issue or not. Thanks forthat at least I learned something!
I will check out unbuffer and pty and report back with my findings.
The watch program
watch -v
procps version 2.0.13
So apparently its part of a bundle of small useful utilities like top,
vmstat, free, kill etc.
Just checked and unfortunately these locked down systems (can't
install software) don't have pty or unbuffer.
If you have watch on your system can you just try to pipe it's output
to a file and let me know if you think it's the buffering issue?
Thanks in advance.
.
- References:
- Confused by unexpected redirection behavior when using the watch command
- From: swordsaintzero
- Re: Confused by unexpected redirection behavior when using the watch command
- From: Icarus Sparry
- Confused by unexpected redirection behavior when using the watch command
- Prev by Date: Re: Confused by unexpected redirection behavior when using the watch command
- Next by Date: Date string script
- Previous by thread: Re: Confused by unexpected redirection behavior when using the watch command
- Next by thread: Re: Confused by unexpected redirection behavior when using the watch command
- Index(es):
Relevant Pages
|