A libary for creating cronjobs for your application methods.
It's on crates.io now, check it out https://crates.io/crates/cronjob.
Add this to your Cargo.toml
under [dependencies]
toml
cronjob = "0.1.1"
This is an example for the unthreaded version.
```Rust extern crate cronjob; use cronjob::{CronJob, gettimezoneoffset};
fn main() {
// Create offset for your required timezone.
let offset = gettimezoneoffset(2);
// Create the CronJob
object.
let mut cron = CronJob::new("Test Cron", "* * * * * * *", offset, oncron);
// Start the cronjob
cron.startjob();
}
// Our cronjob handler fn on_cron(name: &str) { println!("{}: It's time!", name); } ```
This is an example for the threaded version.
```Rust extern crate cronjob; use cronjob::{CronJob, gettimezoneoffset};
fn main() {
// Create offset for your required timezone.
let offset = gettimezoneoffset(2);
// Create the CronJob
object.
let cron = CronJob::new("Test Cron", "* * * * * * *", offset, oncron);
// Start the cronjob
CronJob::startjob_threaded(cron)
}
// Our cronjob handler fn on_cron(name: &str) { println!("{}: It's time!", name); } ```
If you have any issues, please report.