Oil booked a second consecutive monthly gain as front-month futures contracts trade at a premium to later months, typically a sign of a tightening market.