Available since
Time complexity
ACL categories
@admin, @slow, @dangerous

Instruct Redict to start an 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 Redict if there is not already a background process doing persistence.


  • If a Redict child is creating a snapshot on disk, the AOF rewrite is scheduled but not started until the saving child producing the RDB file terminates. In this case the 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 command as of Redict 2.6 or successive versions.
  • If an AOF rewrite is already in progress the command returns an error and no AOF rewrite will be scheduled for a later time.
  • If the AOF rewrite could start, but the attempt at starting it fails (for instance because of an error in creating the child process), an error is returned to the caller.

Since Redict 2.4 the AOF rewrite is automatically triggered by Redict, however the BGREWRITEAOF command can be used to trigger a rewrite at any time.

Please refer to the persistence documentation for detailed information.

Redict logo courtesy of @janWilejan, CC-BY-SA-4.0. Download SVG ⤑

Portions of this website courtesy of Salvatore Sanfilippo, CC-BY-SA-4.0.