> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# Running scheduled cron jobs in Rust using tokio
- URL: https://til.codes/running-scheduled-cron-jobs-in-rust/
- Published: 2022-10-15T07:49:55.000Z
- Updated: 2022-10-16T07:55:12.000Z
- Description: Running periodic/scheduled tasks in Rust using tokio and async/await
- Author: Manu Ajith
- Tags: rust, #Import 2024-07-13 21:01

One common use case when writing backend services is to have the feature to perform some task on a periodic/scheduled manner.

The following code can be used to perform some task on a period manner, using `tokio` and `async/await`

```rust

let mut interval = time::interval(std::time::Duration::from_secs(60));

loop {
    interval.tick().await;
    tokio::spawn(async { perform_task().await; });
}
```