| Crates.io | easycron |
| lib.rs | easycron |
| version | 0.1.2 |
| created_at | 2025-01-22 09:54:59.54875+00 |
| updated_at | 2025-01-23 00:49:14.249579+00 |
| description | rust cron library |
| homepage | |
| repository | https://github.com/peng0208/easycron |
| max_upload_size | |
| id | 1526460 |
| size | 25,914 |
easycron 是一个基于Rust Tokio 的轻量级任务调度库,支持通过 Crontab(秒级) 表达式定义定时任务,支持动态添加、删除、启动、停止定时任务。
cargo add easycron
#[tokio::main]
async fn main() -> Result<()> {
let mut crond = CronBuilder::default().debug(true).build().unwrap();
crond.run().await;
let j1 = Job::new("test", "* * * * * *", || println!("test"))?;
crond.add(j1).await;
sleep(Duration::from_secs(3)).await;
crond.remove(j2.id).await;
tokio::signal::ctrl_c().await?;
Ok(())
}