> For the complete documentation index, see [llms.txt](https://devon-miller.gitbook.io/test_private_book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devon-miller.gitbook.io/test_private_book/miscellaneous/recipe-evaluate-a-task-periodically.md).

# Recipe: Evaluate a Task Periodically

In the above section where we needed to generate an auth token every so often, we used:

```scala
val authStream: Stream[Task, AuthToken] = time.awakeEvery[Task](60.minutes).
  evalMap { _ => Task.delay(AuthToken((math.random * 1000).toInt)) }
```

You can also do something like:

```scala
(eval(authCreationTask).repeat zip time.awakeEvery(1.minute)).map(_._1)
```

which essentially does the same thing. You'll need a Scheduler and Strategy (or an Async) in implicit scope.
