crontab utility for rails

to run any function at periodically in SYSTEM then we can use crontab tool. for the same purpose,is there anything into RAILS project ?

BackgroundRB I think can run scheduled tasks.

Your Rails application will include a script/runner script. You can use it to run (slow-loading) code in the context of your Rails application from cron jobs. Just remember to set RAILS_ENV=production in the crontab in production. :slight_smile:

If your jobs must fire frequently, consider something like backgroundrb instead.

Ciao, Sheldon.

Sheldon Hearn wrote:

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Your Rails application will include a script/runner script. You can use it to run (slow-loading) code in the context of your Rails application from cron jobs. Just remember to set RAILS_ENV=production in the crontab in production. :slight_smile:

If your jobs must fire frequently, consider something like backgroundrb instead.

Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFITkpzpGJX8XSgas0RAvJVAKCXUGf+DqGr16L3YeoURfIS9WjHcgCfcxYO CAo0TZv6hbMUaRCWHAVVJko= =MVCM -----END PGP SIGNATURE-----

i thing

sleep(1.hour) inside another Thread

will it give any problem ?

Why in another thread? Just put it in the main loop of your script.

Ciao, Sheldon.

Quoting Sheldon Hearn <sheldonh@starjuice.net>:

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

> to run any function at periodically in SYSTEM then we can use crontab > tool. > for the same purpose,is there anything into RAILS project ?

Your Rails application will include a script/runner script. You can use it to run (slow-loading) code in the context of your Rails application from cron jobs. Just remember to set RAILS_ENV=production in the crontab in production. :slight_smile:

I'd suggest changing to your application's home/root directory and then invoking the function with script/runner. I found the results variable until I added the change directory. It has been rock solid ever since. For example:

3-58/5 * * * * cd /home/jeff/Rails/amethyst; nice ./script/runner -e development 'Preload.preload' &> /dev/null

Runs at 3, 8, 13, 18, ... minutes after the hour. Calls the preload() function in the Preload module in development mode. And drops the output into the bit bucket. Leave off the "&> /dev/null" part until you are sure it is running without problems. Depending on your setup (e.g. production vs. development databases) you may wish to run in production mode. It may run faster.

HTH,   Jeffrey