Rucron is a lightweight job scheduler, it is similar to gocron or linux crontab, and it is very easy to use.
But now it only supports asynchronous job by the runtime provided by tokio
.
Add this to your Cargo.toml
toml
[dependencies]
rucron = "*"
```rust use rucron::{sync_execute, execute, EmptyTask, Metric, Scheduler}; use std::{error::Error, sync::atomic::Ordering}; use chrono::{Local, DateTime, Duration};
async fn foo() -> Result<(), Box
async fn bar() -> Result<(), Box
async fn ping() -> Result<(), Box
fn once(m: &Metric, last: &DateTime
fn synctask() -> Result<(), Box
async fn main(){
// Create a scheduler with 10 capacity, it will checkout all runnable jobs every second
let sch = Scheduler::
```rust use rucron::{execute, ArgStorage, EmptyTask, ParseArgs, Scheduler}; use std::error::Error; use asynctrait::asynctrait;
struct Person { age: i32, }
impl ParseArgs for Person {
type Err = std::io::Error;
fn parse_args(args: &ArgStorage) -> Result
async fn iseightyears_old(p: Person) -> Result<(), Box
async fn main() {
let child = Person { age: 8 };
// Storage stores all arguments.
let mut arg = ArgStorage::new();
arg.insert(child);
let mut sch = Scheduler::
You could also schedule blocking or CPU-bound tasks.
```rust use rucron::{sync_execute, ArgStorage, EmptyTask, ParseArgs, Scheduler}; use std::error::Error;
struct Person { age: i32, }
impl ParseArgs for Person {
type Err = std::io::Error;
fn parse_args(args: &ArgStorage) -> Result
fn syncsetage(p: Person) -> Result<(), Box
async fn main() {
let child = Person { age: 8 };
let mut arg = ArgStorage::new();
arg.insert(child);
let mut sch = Scheduler::
If you want to schedule jobs with distributed locks, please see [examples] directory.
Rucron is licensed under the MIT license.
Contributions are welcome. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be dual licensed as above, without any additional terms or conditions.