swestrup: (Default)
[personal profile] swestrup
I've got a process that I'd like to monitor that, in debug mode, will issue a semi-infinite list of debug messages to stout.  What I would like to do is have it run in the background and output to some sort of ring-buffer file that only keeps the last 100K or so of output. That way I can occasionally check in on it with a tail -f command without worrying about my hard drive filling with a single huge file.

So, is there such a ring-buffer utility in Linux. I simply assumed that such a thing would exist (after all, dmesg is a ring buffer), but I've not had any luck looking for it. So, does such a file utility exist, or not?

Date: 2009-02-10 03:10 pm (UTC)
ext_290181: (Default)
From: [identity profile] dcoombs.livejournal.com
I'm not aware of one existing... but it would be pretty easy to write a program that reads stdin and keeps the last 1000 lines or so in a file, and then pipe the output of your other program into that.

*shrug*

Date: 2009-02-10 03:39 pm (UTC)
ext_157608: (Default)
From: [identity profile] sfllaw.livejournal.com
The reason such a utility does not exist for on-disk storage is because this would be rather slow and also unsafe. Chopping off the front of a file means copying the entire file.

That's why logrotate exists.

If you want an in-memory ring buffer, then http://vrb.slashusr.org/ has what you want. Exposing this on disk as a fake-file would require some FUSE hacking, though.

Date: 2009-02-10 08:42 pm (UTC)
ext_157608: (Default)
From: [identity profile] sfllaw.livejournal.com
If you think about how modern filesystems are implemented, this is a non-trivial operation.

January 2017

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 13th, 2026 11:09 am
Powered by Dreamwidth Studios