问题
I am working on an application which people can sign up to and schedule tasks to be done.
When the user schedules a task they enter a date and time. I want the application to wake up and send an email to the user at the date and time they have entered.
I am unsure what gems/plugins to use in rails to achieve this, anyone have a suggestion?
Cheers
Eef
回答1:
delayed_job should do the trick. It allows you to schedule tasks to run at a particular time. All you need to do is schedule a function that sends an email.
回答2:
Run a cron job every minute that runs a rake task that checks the database for any un-run tasks in the past.
This way if your system goes down (hint: it will) when you bring it back up the cronjob will pick up the slack left behind.
回答3:
There's also a backgroundrb. Also check this thread.
回答4:
The Unix 'at' command is also useful. Just execute a shell that calls 'at'.
来源:https://stackoverflow.com/questions/4210011/ruby-on-rails-users-scheduling-tasks