Execute Action at a Specified Time

Hey all.   I'm creating an app that that involves sending emails at a specified date-time. I only have one model and it has a "sendat" (:datetime) column. I need to send an email to an email address (also in the model) at the "sendat" time. I'm not sure how to do this.

Run a script/runner via cron job that checks for emails that need to be sent and sends them. I'm thinking something along the lines of "send emails with sendat < now that haven't been sent".

Michael Glaesemann grzm seespotcode net

Heres my method in my Item model:

No, script/runner just runs your code once and then exits. It doesn't do anything magic.

Michael suggested you run script/runner periodically from cron (every 5 minutes, or whatever frequency you need). I think that's the best solution.

You could also make your runner script check for mails, then sleep for a while, then check again, in an endless loop.