We consider the dynamics of a disordered p -spin model with p=2 , analyzing the dynamics within Ruelle's thermodynamic formalism, We use an indicator of the dynamical activity to construct the relevant dynamical Gibbs ensemble. We prove that the dynamics in the low-temperature (spin-glass) phase of the model take place at a second-order phase transition between dynamically active and inactive trajectories. We also show that the same behavior is found in a related model of a three-dimensional ferromagnet.