Category Archives: Cron

I recently had to create a cron job that controlled the delivery of newsletters to a set of subscribers. Unfortunately, the code required some refactoring, but up until it could be modified, the task still needed firing at specific intervals.

I had a little trouble finding much on this subject, so here is the code I eventually used:

./script/runner -e production "app = ActionController::Integration::Session.new; app.get 'account/send_newsletters'"

With any luck, this will help another person save a couple of minutes!

Update

Since Rails 1.2, this method of executing rails controller actions has been throwing an “uninitialized constant ActionController::Integration” exception. Adding the following line to your environments.rb file fixes this problem:

require ‘action_controller/integration’

Thanks, Dimitry Hristov!