Monitor tokio-cron-scheduler Jobs in Rust

Rust

The Problem

tokio-cron-scheduler runs tasks inside your Rust application. If the process dies or a task panics, you need external notification.

The Solution

Add CronRabbit pings inside your scheduled closures. Each task gets its own monitor for independent alerting.

Pattern

Wrap your task logic in a ping start/success/fail pattern. Use catch_unwind to handle panics without crashing the scheduler.

Code Examples

tokio-cron-scheduler with monitoring

Rust
use tokio_cron_scheduler::{JobScheduler, Job};

#[tokio::main]
async fn main() {
    let sched = JobScheduler::new().await.unwrap();

    sched.add(Job::new_async("0 2 * * *", |_uuid, _lock| {
        Box::pin(async {
            let ping = "https://ping.cronrabbit.com/your-id";
            let _ = reqwest::get(format!("{ping}/start")).await;
            match run_backup().await {
                Ok(_) => { let _ = reqwest::get(ping).await; }
                Err(_) => { let _ = reqwest::get(format!("{ping}/fail")).await; }
            }
        })
    }).unwrap()).await.unwrap();

    sched.start().await.unwrap();
}

Ready to Monitor Your Cron Jobs?

Create your free account and add your first monitor in under 5 minutes. No credit card required.