SHUTDOWN [NOSAVE|SAVE]

    The command behavior is the following:

    • Perform a blocking SAVE if at least one save point is configured.
    • Flush the Append Only File if AOF is enabled.
    • Quit the server.

    If persistence is enabled this commands makes sure that Redis is switched off without the lost of any data. This is not guaranteed if the client uses simply and then QUIT because other clients may alter the DB data between the two commands.

    It is possible to specify an optional modifier to alter the behavior of the command. Specifically:

    • SHUTDOWN NOSAVE will prevent a DB saving operation even if one or more save points are configured. (You can think of this variant as an hypothetical ABORT command that just stops the server).

    When the Append Only File is enabled the shutdown may fail because the system is in a state that does not allow to safely immediately persist on disk.

    • The user just turned on AOF, and the server triggered the first AOF rewrite in order to create the initial AOF file. In this context, stopping will result in losing the dataset at all: once restarted, the server will potentially have AOF enabled without having any AOF file at all.
    • A replica with AOF enabled, reconnected with its master, performed a full resynchronization, and restarted the AOF file, triggering the initial AOF creation process. In this case not completing the AOF rewrite is dangerous because the latest dataset received from the master would be lost. The new master can actually be even a different instance (if the REPLICAOF or SLAVEOF command was used in order to reconfigure the replica), so it is important to finish the AOF rewrite and start with the correct data set representing the data set in memory when the server was terminated.

    There are conditions when we want just to terminate a Redis instance ASAP, regardless of what its content is. In such a case, the right combination of commands is to send a CONFIG appendonly no followed by a SHUTDOWN NOSAVE. The first command will turn off the AOF if needed, and will terminate the AOF rewriting child if there is one active. The second command will not have any problem to execute since the AOF is no longer enabled.

    on error. On success nothing is returned since the server quits and the connection is closed.