content/commands/bgrewriteaof.md
Instruct Redis to start an [Append Only File]({{< relref "/operate/oss_and_stack/management/persistence" >}}#append-only-file) rewrite process. The rewrite will create a small optimized version of the current Append Only File.
If BGREWRITEAOF fails, no data gets lost as the old AOF will be untouched.
The rewrite will be only triggered by Redis if there is not already a background process doing persistence.
Specifically:
BGREWRITEAOF will still return a positive status reply, but with an appropriate message. You can check if an AOF rewrite is scheduled looking at the [INFO]({{< relref "/commands/info" >}}) command as of Redis 2.6 or successive versions.Since Redis 2.4 the AOF rewrite is automatically triggered by Redis, however the
BGREWRITEAOF command can be used to trigger a rewrite at any time.
See the [persistence documentation]({{< relref "/operate/oss_and_stack/management/persistence" >}}) for detailed information.
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | |
{{< multitabs id="bgrewriteaof-return-info" tab1="RESP2" tab2="RESP3" >}}
Simple string reply: a simple string reply indicating that the rewriting started or is about to start ASAP when the call is executed with success. The command may reply with an error in certain cases, as documented above.
-tab-sep-
Bulk string reply: a simple string reply indicating that the rewriting started or is about to start ASAP when the call is executed with success. The command may reply with an error in certain cases, as documented above.
{{< /multitabs >}}