- Reference >
- Database Commands >
- Sessions Commands >
- killAllSessions
killAllSessions¶
On this page
Definition¶
-
killAllSessions
¶ New in version 3.6.
The
killAllSessions
command kills all sessions for the specified users.Note
Killing a session kills any in-progress operations in the session, and closes any open cursors associated with these operations. The killed session may still be listed as a current session, and future operations may use the killed session.
The command takes an array of documents that specify the user and database name. Specify multiple array entries to kill sessions for multiple users. Specify an empty array to kill all sessions for all users in the system.
To run
killAllSessions
, use thedb.runCommand( { <command> } )
method.To view existing sessions, see
$listSessions
operation or$listLocalSessions
.See also
Access Control¶
If the deployment enforces authentication/authorization, you must have
the killAnySession
to run the
killAllSessions
command.
Note
Users can kill their own sessions even without
killAnySession
privilege action.