# scheduled-task **Repository Path**: itao007/scheduled-task ## Basic Information - **Project Name**: scheduled-task - **Description**: 对tokio-cron-scheduler库的增强,通过`#[scheduled]`属性宏生成定时任务 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-22 - **Last Updated**: 2025-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 通过`#[scheduled]`属性宏生成定时任务 `#[scheduled]`有两个属性 + cron:指定表达式, 如:cron = "*/1 * * * * *" + rate:指定时间频率,单位:秒, 如:rate = 2 > 注意: cron和rate两者必须且只能有一个有值 `#[scheduled]`必须添加在一个无参数、无返回值的异步函数上, 然后需要执行一下该函数,定时任务才能生效 # Example ```rust #[scheduled(cron = "*/1 * * * * *")] async fn func1() { println!("func1"); } #[tokio::main] async fn main() { run_cron_task!(func1); // 或 // func1().await; } ```