We prove the hydrodynamic limit for a one-dimensional harmonic chain of interacting atoms with a random flip of the momentum sign. The system is open: at the left boundary it is attached to a heat bath at temperature T − , while at the right endpoint it is subject to an action of a force which reads as, where F ⩾ 0 and F (t) is a periodic function. Here n is the size of the microscopic system. Under a diffusive scaling of space-time, we prove that the empirical profiles of the two locally conserved quantities -the volume stretch and the energy -converge, as n → +∞, to the solution of a non-linear diffusive system of conservative partial differential equations with a Dirichlet type and Neumann boundary conditions on the left and the right endpoints, respectively.