[techtalk] Web diary.

Laurel Fan lf25+ at andrew.cmu.edu
Wed Mar 21 11:48:10 EST 2001

Excerpts from linuxchix: 21-Mar-101 [techtalk] Web diary. by Mary
Gardiner at puzzling.o 
> Now there is one problem with the dynamic pages: the mailing list. Is
> there any better way of noticing the addition of a new entry aside from
> a cron job (ie directory notification or something)?

Unfortunately, there isn't any directory notification on Unix.  From
the Unix Programming FAQ:
2.6 How do I find out if a file has been updated by another process?
This is close to being a Frequently Unanswered Question, because people
asking it are often looking for some notification from the system when a
file or directory is changed, and there is no portable way of getting this.
(IRIX has a non-standard facility for monitoring file accesses, but I've
never heard of it being available in any other flavour.)
In general, the best you can do is to use `fstat()' on the file. (Note: the
overhead on `fstat()' is quite low, usually much lower than the overhead of
`stat()'.) By watching the mtime and ctime of the file, you can detect when
it is modified, or deleted/linked/renamed. This is a bit kludgy, so you
might want to rethink *why* you want to do it.

A cron job might seem inelegant, but to me, it doesn't look that bad,
especially since I think that people following it through email don't
have to be real-time.  Web and email in general have different
latencies; when I want to see a web page, I expect to get it in
seconds, but when I email someone, the expected timeframe for a
response is more like a few hours to a few days.

Depending on the nature of your diary, it may actually be better to
run the check-for-updates-and-email-people script once a day instead
of just sending updates immediately.  This gets you automatic
digesting.  It allows you to add to your diary throughout the day,
keeping the web readers up to the minute, without worrying about
filling up the mailboxes of the email readers.

(Of course, I am probably not the one to ask.  Were I to do this, I
would combine make, cvs, and the remote execution feature of ssh, with
a handful of perl/C/bash programs, and probably some "nontraditional"
programming languages such as octave, gnuplot, or the C preprocessor,
so that I could type in my entry somewhere, commit it to cvs, type
make to create the web pages, and use a cvs commit notification script
to email it.)

More information about the Techtalk mailing list