cron_tab 0.1.1

A cron job library for Rust.
Documentation

CronTab

A cron job library for Rust.

Usage

Please see the Documentation for more details.

Add to your Cargo.toml:

[dependencies]
cron_tab = "0.1.1"

The cron expression format:

sec   min   hour   day of month   month   day of week   year
*     *     *      *              *       *             *

Example:

extern crate cron_tab;  
  
use chrono::{FixedOffset, Local, TimeZone, Utc};  
  
fn main() {  
 let local_tz = Local::from_offset(&FixedOffset::east(7));  
 let utc_tz = Utc;  
  
 let mut cron = cron_tab::Cron::new(utc_tz);  
  
 let job_test_id = cron.add_fn("* * * * * * *", test).unwrap();  
  
  cron.start();  
  
  std::thread::sleep(std::time::Duration::from_secs(2));  
 let anonymous_job_id = cron  
        .add_fn("* * * * * *", || {  
            println!("anonymous fn");  
  })  
        .unwrap();  
  
  // remove job_test  
  cron.remove(job_test_id);  
  
  std::thread::sleep(std::time::Duration::from_secs(2));  
  // stop cron  
  cron.stop();  
}  
  
fn test() {  
    println!("now: {}", Local::now().to_string());  
}

License