#job #periodic #cron-job #cron #jobs #minutes

schedule

An in-process scheduler for periodic jobs. Schedule lets you run Rust functions on a cron-like schedule.

1 unstable release

Uses old Rust 2015

0.1.0 Feb 1, 2017

#19 in #minutes

Download history 21/week @ 2024-03-11 20/week @ 2024-03-18 23/week @ 2024-03-25 42/week @ 2024-04-01 13/week @ 2024-04-08 15/week @ 2024-04-15 23/week @ 2024-04-22 14/week @ 2024-04-29 13/week @ 2024-05-06 18/week @ 2024-05-13 17/week @ 2024-05-20 32/week @ 2024-05-27 17/week @ 2024-06-03 9/week @ 2024-06-10 13/week @ 2024-06-17 15/week @ 2024-06-24

61 downloads per month
Used in 2 crates

MIT/Apache

12KB
253 lines

schedule-rs

An in-process scheduler for periodic jobs. Schedule lets you run Rust functions on a cron-like schedule.

Install

[dependencies]
schedule = "0.1"

Usage

extern crate schedule;
extern crate chrono;

use schedule::{Agenda, Job};
use chrono::UTC;

fn main() {
    let mut a = Agenda::new();

    // Run every second
    a.add(Job::new(|| {
        println!("at second     :: {}", UTC::now());
    }, "* * * * * *".parse().unwrap()));

    // Run every minute
    a.add(Job::new(|| {
        println!("at minute     :: {}", UTC::now());
    }, "* * * * *".parse().unwrap()));

    // Run every hour
    a.add(Job::new(|| {
        println!("at hour       :: {}", UTC::now());
    }, "0 * * * *".parse().unwrap()));

    // Check and run pending jobs in agenda every 500 milliseconds
    loop {
        a.run_pending();

        std::thread::sleep(std::time::Duration::from_millis(500));
    }
}

License

config-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Dependencies

~3MB
~51K SLoC