[erlang-questions] request a task scheduler

Robert Raschke rtrlists@REDACTED
Mon Aug 31 17:45:34 CEST 2009


On Mon, Aug 31, 2009 at 4:13 PM, info <info@REDACTED> wrote:

>  Hi Robby,
> It seems that we cannot schedule tasks every 30 seconds or 5 minutes. Am I
> wrong ?
> John
>
> On Mon, Aug 31, 2009 at 2:56 PM, info  <info@REDACTED > wrote:
>
> > Hi all,
> >
>
> > Excepted crone.erl do you know a task scheduler for erlang OTP application
> > ?
> > I look for a task scheduler with a fine timing (seconds, minutes, ...,
> > months, ...).
> >
> > John
> >
>
>
> What's wrong with crone? Seems to fit the bill, except for tasks run at very
> large intervals. I guess the other thing missing from crone is scheduling
>
> against UTC instead of local time. Otherwise it's pretty trivial to mould to
> your needs.
>
> If you need scheduling on a yearly basis, you should be able to take the
> crone code and put a wrapper with coarse granularity around it very easily.
>
> Robby
>
>

The {daily, {every, {5, sec}, {between, {12, 0, 0, am}, {11, 59, 59, pm}}}}
schedule works fine for me. (Disclaimer, I've changed the until_next_time()
function to use simple 24 hour days for myself, so I hope that schedule is
correct for the crone.erl you can get online.)

I don't use the surrounding invocation code provided by crone though. I just
use the until_next_time() to get me the amount of time to put into my
gen_server timeout return values. The one thing that is a bit awkward is
dealing with milli-seconds. The crone code only goes to second granularity.
So if your task is over in less than a second, be sure to not invoke it
again by accident. If I remember correctly there was some explicit
sleep(1000) in the crone invocation code itself.

Robby


More information about the erlang-questions mailing list