Gripe water

When is best to give gripe water? Before baby gets fussy? Or when baby gets fussy? The bottle says not to give when baby is crying. So is it given before to prevent the fussing? My baby gets fussy right before bed and at 5 am is when he tries to poop and is grunty and fussy and arching back.