My application needs to send email reminders to people before certain
events. I think cron job is the way to go which will run every hour.
Rather than putting the database connection and all the business rules
in
the shell script , I was wondering if there is a better way. I haven’t
used
rake but is it possible to write a rake job and execute it through a
cron
job. Any suggestions on handling these kinds of issues.
My application needs to send email reminders to people before certain
events. I think cron job is the way to go which will run every hour.
Rather than putting the database connection and all the business rules in
the shell script , I was wondering if there is a better way. I haven’t used
rake but is it possible to write a rake job and execute it through a cron
job. Any suggestions on handling these kinds of issues.
Define a method in the appropriate model and then call it like this from
cron:
Rather than putting the database connection and all the business
rules in the shell script , I was wondering if there is a better
way. I haven’t used rake but is it possible to write a rake job and
execute it through a cron job. Any suggestions on handling these
kinds of issues.
It sure is possible to run a rake command from cron. However, you can
also use script/runner for this:
./script/runner “your code goes here”
So for example script/runner “require ‘send_reminders’” or script/
runner ‘Reminder.deliver_all’ can be run from your cronjob.