views:

184

answers:

3

Hello,

I am currently using the delayed_job gem and I was wondering how to run a rake task every 5 minutes.

I want to run "rake ts:reindex RAILS_ENV=production" every 5 minutes but I'm not sure where to start. I really don't have much more I can say about this because I am VERY inexperienced in this area of rails development.

+1  A: 

I would not suggest using thinking sphinx reindexing every 5 minutes. If you really want that put something like this into your /etc/crontab:

*/5 * * * * your_username cd /path/to/rails/root && rake ts:reindex RAILS_ENV=production
Eimantas
+1  A: 

Thinking Sphinx (assuming you're using it due to the ts:reindex mention) has internal hooks to use delayed job for indexing. Have you taken a look at delayed delta indexing? You will probably end up using the crontab to actually run the periodic delta reindex as Eimantas mentioned.

x1a4
+1  A: 

Use the Whenever gem to schedule your reindexing rake task or any other rake task to run every 5 minutes.

Its makes it very easy to create Cron jobs like these

Rishav Rastogi
What if you don't want to use rake so that you can avoid rails starting up every time you need to run a DJ?
tesmar