I'm currently creating a rails application and would like to find out how to schedule certain tasks to run at a specific time.
For e.g. An admin would want to send emails to his users at 8:00am in the morning and does not want to wake up early just to send that email. Therefore, he/she would want to schedule the task to send emails at that time.
So, is there a way, or better still a gem, that allows tasks to be scheduled to run at a specific time? Thanks!
My preferred solution here is the Whenever gem.
With it, you have
schedule.rb
file, which specifies when certain things should be done, including running rake tasks, executing methods, or even executing arbitrary shell commands:Example schedule.rb file, shamelessly copied from the Whenever readme:
I use Whenever for a number of tasks, including sending daily emails.