Howto get stuff to happen automatically?

I’m trying to get certain emails sent at a certain datetime.
So I have a column in my table called “due_by”, as soon as it’s overdue
is it possible to get an automatic email notification?

How do people get stuff like this to happen via. Rails without user
interaction?

TIA
Luke

You would need some sort of script that queues your table for any
email notifications that are due. An easy way to do this with your AR
models is to make a rake task which checks for any items due and sends
them.

You could have this run every 5 minutes or so using a cron job.

A more advanced solution might offload this to an external queue which
your script could poll from in an infinite loop.

Just some ideas…

On Jan 14, 8:13 pm, Luke G. [email protected]

Hmm, yeah I thought about just making it a cronjob, but I’m not too sure
if an external infinite loop is a good idea…

Is a cronjob the most common method of getting it done? or is there
something else that everyone uses?

backgroundrb lets you schedule ruby tasks like cronjobs.

On Jan 15, 2008 3:25 PM, Luke G.
[email protected]
wrote:


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

It doesn’t have to be a cron job. You can just have your app run an
infinite loop e.g.:

loop do

script code

end

and then manage this script with god. It’d be more responsive this
way.

On Jan 14, 8:55 pm, Luke G. [email protected]

"A more advanced solution might offload this to an external queue
which
your script could poll from in an infinite loop. "

How would that effect your local database?

On Jan 14, 9:23 pm, Luke G. [email protected]

A loop like that would have serious performance implications on the
server if it’s hitting the database, checking a couple of values and
sending emails each trip wouldn’t it?

Oh, btw Ryan, cheers for backgroundrb, that looks good. I might use
that.

eggie5 wrote:

It doesn’t have to be a cron job. You can just have your app run an
infinite loop e.g.:

loop do

script code

end

and then manage this script with god. It’d be more responsive this
way.

On Jan 14, 8:55 pm, Luke G. [email protected]