Rails · Rails Scheduler

Monitor Rails Scheduled Tasks

Not every recurring Rails job goes through Sidekiq — a plain rake task or runner script triggered directly by cron (often via the whenever gem, or Rails 7.1+'s built-in recurring tasks) is just as common, and monitors the same simple way.

Setup

1

Create an incoming monitor

Add a heartbeat monitor in Pingtastic with a grace period past the task's schedule interval.

2

Ping at the end of the rake task

Add the ping call after the task's real work completes.

lib/tasks/nightly_cleanup.rake
task nightly_cleanup: :environment do
  # ...existing task logic...

  Net::HTTP.get(URI('https://ping.pingtastic.net/ping/nightly-cleanup'))
end
3

Schedule it

Via the whenever gem's schedule.rb (which generates the crontab for you), or a plain crontab entry.

config/schedule.rb
every 1.day, at: '3:00 am' do
  rake "nightly_cleanup"
end

Gotchas

  • ⚠The whenever gem only writes your crontab when you run `whenever --update-crontab` — a schedule.rb change that was never deployed with that command silently has no effect, with nothing in Rails itself indicating a mismatch.
  • ⚠Rake tasks run via cron get a minimal environment — make sure RAILS_ENV and any required env vars are set explicitly in the cron command or schedule.rb, not assumed from an interactive shell.

Questions

Is this different from monitoring Sidekiq?

Yes — this is for jobs that run as plain rake tasks or runner scripts on a schedule, with no background job queue involved. See Monitor Sidekiq Scheduled Jobs if your recurring work goes through Sidekiq instead.

Do I need the whenever gem?

No — it's a convenience for generating crontab entries from Ruby syntax. A plain crontab entry calling bundle exec rake nightly_cleanup works identically for monitoring purposes.

Start monitoring your Rails rails scheduler

Set up your first monitor in under five minutes.

Get started — $5/month