
Show HN: Lightweight job scheduling for Node.js - rschmukler
http://github.com/rschmukler/agenda?
======
imtu80
I am working on a scheduled reminder (email/SMS service) to send
notifications. I've been looking for a scheduling/Cron service for node. There
are few I am evaluating. I will consider yours. If I reboot the machine or
node server, will it automatically queue up the jobs?

~~~
rschmukler
So if you reboot the server, you just need to make sure that you call
agenda.start() again. This will start the job processor which looks for jobs
that have come due in the database and process them. agenda.every('3 minutes',
'job name') is a special case in which it will only schedule that job once
(because if you think about it, otherwise every time you ran that line you'd
get a new job... This makes it so you can define it in the same file as where
you call agenda.start() and not end up defining new versions of those
repeating jobs every time the file gets ran). Hope this makes sense/helps.

------
bunkat
If you wanted even more flexible schedules, you might want to look into
Later.js ([http://bunkat.github.io/later/](http://bunkat.github.io/later/)), a
small library I created just for this purpose. It supports composite and
exception schedules, cron schedules, and lots of different time periods.
Everything can be specified using an API or using English text.

I also built replacements for setTimeout and setInterval to use Later
schedules, so it should be easy enough to plug it into your solution.

~~~
rschmukler
Very cool. How robust is the english parsing? For example, would it understand
something like "The first wednesday of every month"? Either way I will
definitely check it out.

~~~
bunkat
You can see the grammar and lots of examples at
[http://bunkat.github.io/later/parsers.html#text](http://bunkat.github.io/later/parsers.html#text).
For your question, it would be 'on Wednesday on the first day instance every 1
month' or 'on the first day instance on Wed' would also work.

------
weixiyen
Curious, why the choice of mongo vs something like redis?

~~~
baudehlo
I thought the same. For redis there's Kue, which looks a lot more feature
complete.

[https://github.com/learnboost/kue](https://github.com/learnboost/kue)

~~~
rschmukler
See above for Mongo vs Redis. As for "feature completeness", this is a pretty
feature complete job scheduling library. It leaves the writing of a Web
interface to someone else, but for scheduling jobs it gets the job done.
(Haha, that pun was irresistible)

------
rmrfrmrf
Any word on how this affects battery life, specifically on Macs? I've had to
turn on atrun on my MacBook Air and it has absolutely destroyed my battery
life.

~~~
rschmukler
I haven't tested on a laptop be honest. Interesting point. What is atrun? I'll
do some research and see if I can do anything about it... For reference node
idles at about 3% CPU on my dev-box.

------
fourstar
This is perfect. Thanks.

