Typically, you should use a shard balancing window to specify when the balancer runs instead of manually starting and stopping defragmentation.
To manually stop defragmenting a sharded collection, use the
configureCollectionBalancing command with the
defragmentCollection option set to false.
About this Task
The procedure in this task uses an example sharded collection named
ordersShardedCollection in a database named test.
You can use your own sharded collection and database in the procedure.
If you stop defragmenting a collection before defragmentation is complete, the collection is in a partially defragmented state and operates as usual. To resume defragmentation, restart the process.
Before you Begin
- Start defragmenting a sharded collection. For details, see Start Defragmenting a Sharded Collection. 
- Connect to - mongos.
Procedure
Ensure defragmentation stopped
When defragmentation stops, the command output returns ok: 1:
{    ok: 1,    '$clusterTime': {       clusterTime: Timestamp({ t: 1678834337, i: 1 }),       signature: {          hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),          keyId: Long("0")       }    },    operationTime: Timestamp({ t: 1678834337, i: 1 }) } 
Next Steps
You can start defragmentation again at any time. For details, see Start Defragmenting a Sharded Collection.
Learn More
- Print shard status, see - db.printShardingStatus()
- Retrieve shard status details, see - sh.status()
- View shard status collection fields, see Sharded Collection 
- See active mongos instances, see Active - mongosInstances
- Monitor shards using MongoDB Atlas, see Review Sharded Clusters