# AUDIT.ROTATE

> Close the current audit log file, keep it under a timestamped name, and start a new one.

URL: https://docs.hotkv.com/commands/audit-rotate/

```
AUDIT.ROTATE
```

- Group: Audit
- Complexity: O(1)
- HotKV Cloud: Scale plan
- On-Premise: requires the audit-log license feature

`AUDIT.ROTATE` renames the current audit log file to
`<file>.<YYYYMMDD_HHMMSS>` (the time in UTC) and starts writing new entries
to a fresh file under the configured name. Use it to archive the log on your
own schedule. HotKV also rotates on its own once the file grows past
`max_size` (`audit.max-size`, 100 MB by default).

[AUDIT.VERIFY](https://docs.hotkv.com/commands/audit-verify/index.md) and
[AUDIT.EXPORT](https://docs.hotkv.com/commands/audit-export/index.md) work on the current file only, so
export or verify the log before you rotate it if you need the old entries
in one piece. The command cannot be called from a script.

## Return value

Simple string `OK` in RESP2 and RESP3, or one of these errors:

| Case | Error |
| --- | --- |
| Audit logging is off (`audit.enabled` is `no`) | `ERR audit logging is not enabled` |
| The new log file could not be opened | `ERR audit log rotation failed, see the server log` |
| No license that includes `audit-log` | `NOLICENSE audit-log requires a HotKV license. Contact sales@hotkv.com` |

If the log file was removed from outside while the server ran, the command
starts a new file and answers `OK`; the server log records a warning.

## Examples

```
127.0.0.1:6379> AUDIT.ROTATE
OK
```

## Compatibility

HotKV-only command.

## See also

[AUDIT.INFO](https://docs.hotkv.com/commands/audit-info/index.md), [AUDIT.EXPORT](https://docs.hotkv.com/commands/audit-export/index.md)