# Clocks

URL: https://zerodev.ca/docs/kora/developer-documentation/clocks

> Run a task on a schedule.



A clock runs `run()` on a cron schedule. Put clocks in `src/clocks/`.

```js title="modules/example/src/clocks/cleanup.js"
import { Clocks } from "#kora/modules";

export class Cleanup extends Clocks {
    constructor(kora) {
        super(kora, { name: "cleanup", schedule: "0 0 * * *" });
    }

    async run() {
        const removed = await this.kora.modules.handlers.get(this.module, "items").purge();
        if (removed > 0) this.kora.console.log(this.kora.console.levels.info, `Removed ${removed} old items.`);
    }
}
```

| Key        | What it does                                                                                                 |
| ---------- | ------------------------------------------------------------------------------------------------------------ |
| `name`     | The clock name.                                                                                              |
| `schedule` | A 5-field cron expression: minute, hour, day, month, weekday.                                                |
| `timezone` | Optional IANA zone for the schedule, such as `UTC` or `Europe/Berlin`. Without it the server's zone is used. |

| Schedule       | Runs                      |
| -------------- | ------------------------- |
| `*/10 * * * *` | Every 10 minutes.         |
| `0 * * * *`    | Every hour.               |
| `0 0 * * *`    | Every day at midnight.    |
| `0 0 * * 0`    | Every Sunday at midnight. |

Clocks start once Kora has finished starting and stop when the module is turned off. Core uses them to expire licenses every 10 minutes and remove old validation logs every hour.
