Out of equilibrium thermodynamics of quantum harmonic chains