Java has a file watch API to avoid polling. Stuart Sierra uses it to
good effect in lazytest.


On Dec 2, 9:14 am, Alex Osborne <a...@meshy.org> wrote:
> viksit <vik...@gmail.com> writes:
> > What would you recommend as the best method to tail a file using
> > Clojure? Are there any built in functions in contrib or core that
> > allow a program to read the last line of a file as it is appended to?
> > If not - how do people solve a problem like this?
>
> > My aim is simple - I've got a log file and I'd like to parse it as it
> > gets appended to.
>
> Tail just polls the file every 1 second or whatever (it's configurable
> -s option) and check's if the file's length has changed.  You can do
> this yourself easily enough.
>
> Some discussion here (it's Java, but you'd do exactly the same in Clojure):
>
> http://stackoverflow.com/questions/557844/java-io-implementation-of-u...
>
> When I've had this problem myself (on unix), I've just been lazy and
> implemented it by doing:
>
> tail -f somefile.log | java ...
>
> Or shelling out to `tail' from within the program.  Ugly perhaps, but I
> know GNU tail behaves the way I want when the file is truncated and
> such. :-P

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to