Crate cronjob [−] [src]
cronjob
The cronjob
library lets you create cronjobs for your methods.
Getting started
extern crate cronjob; use cronjob::CronJob; fn main() { // Create the `CronJob` object. let mut cron = CronJob::new("Test Cron", on_cron); // Start the cronjob. cron.start_job(); } // Our cronjob handler. fn on_cron(name: &str) { println!("{}: It's time!", name); }
schedule
The cronjob
allows to optionally add schedule parameters.
extern crate cronjob; use cronjob::CronJob; fn main() { // Create the `CronJob` object. let mut cron = CronJob::new("Test Cron", on_cron); // Set seconds. cron.seconds("0"); // Set minutes. cron.minutes(0); // Start the cronjob. cron.start_job(); } // Our cronjob handler. fn on_cron(name: &str) { println!("{}: It's time!", name); }
Threaded
extern crate cronjob; use cronjob::CronJob; fn main() { // Create the `CronJob` object. let mut cron = CronJob::new("Test Cron Threaded", on_cron); // start the cronjob. CronJob::start_job_threaded(cron); } // Our cronjob handler. fn on_cron(name: &str) { println!("{}: It's time!", name); }
Structs
CronJob |
The object to create and execute cronjobs for yout application. |