Fix the maintenance script

It should wait for slave during each batch update

Change-Id: Iba8b172016317236981c11b4f9af9bb1723516ec