[Lxc-users] Piping output of lxc-monitor to a file without buffering

Ken Elkabany Ken at Elkabany.com
Tue Sep 11 01:28:06 UTC 2012


I found a simple workaround by using the unbuffer utility, which uses a
pseudo terminal to get the desired line-buffering-only behavior.

$ unbuffer lxc-monitor -n container-1 > output

Ken

On Fri, Sep 7, 2012 at 5:25 PM, Ken Elkabany <Ken at elkabany.com> wrote:

> On Thu, Sep 6, 2012 at 11:13 PM, Fajar A. Nugraha <list at fajar.net> wrote:
>
>> On Fri, Sep 7, 2012 at 7:46 AM, Ken Elkabany <Ken at elkabany.com> wrote:
>> > Hi,
>> >
>> > The following outputs container state changes to the terminal as
>> expected:
>> >
>> > $ lxc-monitor -n container-1
>> >
>> > However, the following outputs the same state changes to a file only
>> after a
>> > certain buffer size has been reached:
>> >
>> > $ lxc-monitor -n container-1 &> output
>> >
>> > This is problematic because it means that live monitoring cannot be
>> done by
>> > a separate program. The buffering delays messages, potentially
>> indefinitely.
>> >
>> > Is there a way around this?
>>
>> (optional: start a screen session)
>> $ script -f /path/to/your-logfile.txt
>> $ lxc-monitor -n container-1
>>
>> ... and on other terminal
>> $ tail -f /path/to/your-logfile.txt
>>
>> --
>> Fajar
>>
>
> Unfortunately, in my application there won't be any open terminals. I
> simply used that as an example to illustrate my point.
>
> Ken
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20120910/19b2b2d2/attachment.html>


More information about the lxc-users mailing list