https://github.com/mehcode/schedule-rs
An in-process scheduler for periodic jobs. Schedule lets you run Rust functions on a cron-like schedule.
https://github.com/mehcode/schedule-rs
cron job rust schedule task
Last synced: 6 months ago
JSON representation
An in-process scheduler for periodic jobs. Schedule lets you run Rust functions on a cron-like schedule.
- Host: GitHub
- URL: https://github.com/mehcode/schedule-rs
- Owner: mehcode
- License: apache-2.0
- Created: 2017-02-01T22:26:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-06T20:56:50.000Z (almost 7 years ago)
- Last Synced: 2025-04-02T21:38:01.671Z (6 months ago)
- Topics: cron, job, rust, schedule, task
- Language: Rust
- Size: 16.6 KB
- Stars: 121
- Watchers: 4
- Forks: 12
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# schedule-rs

[](https://crates.io/crates/schedule)
[](https://docs.rs/schedule)
> An in-process scheduler for periodic jobs. Schedule lets you run Rust functions on a cron-like schedule.## Install
```toml
[dependencies]
schedule = { git = "https://github.com/mehcode/schedule-rs" }
```## Usage
```rust
extern crate schedule;
extern crate chrono;use schedule::Agenda;
use chrono::UTC;fn main() {
let mut a = Agenda::new();// Run every second
a.add(|| {
println!("at second :: {}", UTC::now());
}).schedule("* * * * * *").unwrap();// Run every minute
a.add(|| {
println!("at minute :: {}", UTC::now());
}).schedule("0 * * * * *").unwrap();// Run every hour
a.add(|| {
println!("at hour :: {}", UTC::now());
}).schedule("0 0 * * * *").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
Schedule 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.