Schedule tasks

Hi,

I need some help to schedule some tasks.

I have a database table with a column called: start

I need to send an email and update a column at that start date.

How can I iterate my database table, verify if today has some tasks to be executed and send an email.

Thanks.

You have described a problem with a large number of aspects. Which particular bit do you not know how to do? Running a background job? Iterating the table? Testing whether you have to do something? Sending the email? Updating the database? Anything else?

Colin

Sorry Colin,

Actually I need help about how can I run a background job.

This job needs to listen all events registered in database and send an email when the dates match.

I’m found clockwork gem as an option to do this.

I have to create a worker that runs every minute and verifies if current date/time is the same from the event in the database.

Is it a good alternative ?

Thanks.

Sorry Colin,

Actually I need help about how can I run a background job. This job needs to listen all events registered in database and send an email when the dates match.

I'm found clockwork gem as an option to do this. I have to create a worker that runs every minute and verifies if current date/time is the same from the event in the database. Is it a good alternative ?

Well you can tell us that. If it working well and was easy to implement then yes. I don't know how you have coded it but a suggestion is to put all the logic in a method of one (or more) of the models and then just call that from the worker. That way the code is easier to test using your automated tests.

I would probably just have written a rake task and called it from cron, but I have not tried the clockwork gem so maybe it is a good alternative. Does it play well with rails? I notice that it has not been updated for a year or so, but maybe that is not an issue.

Colin