How to Monitor Ruby Cron Jobs with CronRabbit
RubyThe Problem
Ruby scripts run by cron can raise unhandled exceptions, hit memory issues with the GC, or fail to load gems. Without monitoring, failures go unnoticed.
The Solution
Add a Net::HTTP call to CronRabbit at the end of your Ruby script to confirm successful execution.
Integration
Use Ruby's built-in Net::HTTP or the httparty gem. Place the ping after all critical logic so it only fires on success.
Code Examples
Basic monitoring with Net::HTTP
Rubyrequire 'net/http'
PING = "https://ping.cronrabbit.com/your-id"
def ping(path = "")
uri = URI("#{PING}#{path}")
Net::HTTP.get(uri) rescue nil
end
ping("/start")
begin
run_data_export
ping
rescue => e
ping("/fail")
raise
end