For regular tasks of the sort you describe, especially things like
sending out regular emails, backing up systems, and other maintenance
tasks, you may want to consider using cron on a unix machine instead.
Cron is a super old (read, highly configurable and well-understood)
piece of software (or family of nearly identical implementations,
anyway) that is designed exactly to trigger recurring tasks.

In each line of the configuration file (the "crontab"), one specifies
the text of a command and the month(s), day(s), day(s) of week,
hour(s), minute(s), and second(s). The command can be an arbitrary
terminal command, program, or shell script.

See http://en.wikipedia.org/wiki/Cron and scroll down to the "fields"
section.

In the 0.25M LOC system I program for at work, we write standalone
methods in Java (how I wish that some of them were in clojure) and use
cron to call them via JMX. Not only does this separate the timing code
from the thing being timed, but it puts the timing of these regular
(daily, weekly, hourly, etc.) background jobs in the hands of the
operations team, who can easily do things like turn them off during
upgrades or reschedule them when our usage patterns change.

I know this completely fails to answer your original question about
Timer, and it introduces more moving parts into your software, but
having fallen into this trap at least once I feel compelled to try to
spare you the pain of trying to reimplement unix cron.

Cheers.
--josh


On Sep 1, 5:11 pm, Mathias Dahl <[EMAIL PROTECTED]> wrote:
> I would like to have a java.util.Timer running in my Clojure webapp.
> Once per week, some time each Friday, the code the timer calls would
> send out an e-mail with news to a list of recipients. I have never
> used Timers nor worked with threads in Java so this is kind of new
> ground to me. I found some piece of code on Sun's site (http://
> java.sun.com/products/jfc/tsc/articles/timer/) but did not understand
> how to translate that to Clojure.
>
> Has anyone here tried doing anything similar in Clojure?
>
> Thanks!
>
> /Mathias
--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to