- Reference >
- Database Commands >
- Sessions Commands >
- killAllSessionsByPattern
killAllSessionsByPattern¶
On this page
Definition¶
-
killAllSessionsByPattern
¶ New in version 3.6.
The
killAllSessionsByPattern
command kills all sessions that match any of the specified patterns:The command takes an array of documents that specify the patterns to match:
Pattern Description { lsid: { id : <UUID> } }
Specify the UUID portion of the session id to kill. { uid: <BinData> }
Specifies the hash of the owner of the sessions to kill. { users: [ { user: <user>, db: <dbname> }, ... ] }
Specifies the owners of the sessions to kill. Requires additional privileges. See Access Control. { roles: [ { role: <role>, db: <dbname> }, ... ] }
Specifies the roles assigned to the owners of the sessions to kill. Requires additional privileges. See Access Control. Specify an empty array to kill all sessions.
To run
killAllSessionsByPattern
, 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
killAllSessionsByPattern
command.
For patterns that include users
or roles
, you must also have
privileges that grant impersonate
action on the cluster
resource.
Note
Users can kill their own sessions even without
killAnySession
privilege action.