Re: Periodic tasks

2009-11-04 Thread sross
You could also try cron4j which, while less customisable than quartz, is far simpler to use. It also accepts Runnable's as as tasks which allows for much easier clojure integration. user=> (def sched (it.sauronsoftware.cron4j.Scheduler.)) #'user/sched user=> (.schedule sched "* * * * *" #(printl

Re: Periodic tasks

2009-11-03 Thread MarkSwanson
> I'd love to hear success stories from people using nailgun to actually > run frequent scripted tasks out of cron, as opposed to for > development. It would make clojure more palatable for my work > environment. Nailgun has been a boon to me. I don't believe Nailgun has a problem with dynamic cl

Re: Periodic tasks

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 7:39 PM, Jonathan Smith wrote: > > Maybe I'm confused, but can't you just do a regular java thread for > this? > > (defn periodicly [fun time] > "starts a thread that calls function every time ms" > (let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time) > (recur

Re: Periodic tasks

2009-11-01 Thread Jonathan Smith
Maybe I'm confused, but can't you just do a regular java thread for this? (defn periodicly [fun time] "starts a thread that calls function every time ms" (let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time) (recur] (.start thread) thread)) (periodicly #(println "foo

Re: Periodic tasks

2009-11-01 Thread John Harrop
On Sun, Nov 1, 2009 at 3:20 PM, Emeka wrote: > John, > > Is like I am missing something? This thread mentioned making periodic > tasks, there was a java example to it. However, what you posted I am yet to > figure out how to make a periodic tasks possible. > Agents can perform periodic tasks, if

Re: Periodic tasks

2009-11-01 Thread Emeka
John, Is like I am missing something? This thread mentioned making periodic tasks, there was a java example to it. However, what you posted I am yet to figure out how to make a periodic tasks possible. Regards, Emeka On Sat, Oct 31, 2009 at 6:27 PM, John Harrop wrote: > On Sat, Oct 31, 2009 a

Re: Periodic tasks

2009-10-31 Thread John Harrop
On Sat, Oct 31, 2009 at 12:36 PM, Luke VanderHart wrote: > Why not just run an agent that does something, then calls sleep for N > seconds, then calls the next thing? > > Granted, it will eat up a thread in your agent thread pool, but if > you've only got one of these in the app it shouldn't be a

Re: Periodic tasks

2009-10-31 Thread cody koeninger
On Oct 31, 11:42 am, Richard Newman wrote: > VimClojure relies on Nailgun, with a bunch of people on this list   > using it with Clojure every day. My recollection from list and IRC was that (aside from random nailgun issues + the project not being updated in 4 years) there was an issue with d

Re: Periodic tasks

2009-10-31 Thread Richard Newman
> > Overhead from starting and stopping the JVM every couple of minutes > would probably be unacceptable. My understanding is that solutions > like Nailgun don't work correctly with Clojure either. VimClojure relies on Nailgun, with a bunch of people on this list using it with Clojure every da

Re: Periodic tasks

2009-10-31 Thread Luke VanderHart
Why not just run an agent that does something, then calls sleep for N seconds, then calls the next thing? Granted, it will eat up a thread in your agent thread pool, but if you've only got one of these in the app it shouldn't be a problem. Or you could go the Java route, and start a daemon threa

Re: Periodic tasks

2009-10-31 Thread cody koeninger
On Oct 31, 5:22 am, alxtoth wrote: > Why not use the OS task scheduler? On un*x there is good old cron or > at. On windoze there is similar task scheduler. > Overhead from starting and stopping the JVM every couple of minutes would probably be unacceptable. My understanding is that solutions

Re: Periodic tasks

2009-10-31 Thread alxtoth
Hi Why not use the OS task scheduler? On un*x there is good old cron or at. On windoze there is similar task scheduler. If you think a little that's what it takes: simple reliable and if it fails with whatever error will start again in 2 minutes. Just don't forget to write to log files , and ro

Re: Periodic tasks

2009-10-30 Thread AndrewC.
On 30 Oct, 16:18, Albert Cardona wrote: > How about: > > (import '(java.util.concurrent Executors TimeUnit)) .. > Admittedly very java-ish. Personally, I think Java-ish is the way to go here. John's actor lib is pretty nifty, but it is relying on implementation details of the threading o

Re: Periodic tasks

2009-10-30 Thread Albert Cardona
How about: (import '(java.util.concurrent Executors TimeUnit)) (let [s (Executors/newSingleThreadScheduledExecutor)] (.scheduleAtFixedRate s #(try (println "I did it again") (catch Exception e (.printStackTrace e))) (long 0) (long 1) TimeUnit/SECONDS)) Adm

Re: Periodic tasks

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 12:05 AM, Stefan Arentz wrote: > What is a good and simple way to run periodic tasks in Clojure? I need > to run a simple function every couple of minutes. And make sure that > if it throws an exception that it won't kill the periodic task. > > I come from a Spring world w