I am learning Rails and came across the following problem.
I need to do some daily maintenance to the MySQL database. By
maintenance, I mean reading data from one table, do some calculation,
and put the result in another table. This should happen everyday at a
specified time, e.g., at mid-night, no matter if there is any visitor
visiting the site or not. Ideally this should happen quietly in the
background without any human intervention.
How can I do it in Rails?
I understand that in some other environments like PHP I could do it in
at least two ways:
- Write a stored procedure for the daily maintenance;
- Write a standalone script for the daily maintenance and use cron to
schedule it to run once per day;
But these two are pretty un-Rails. So what should I do for tasks like
this in a Rails way?