At intermediate intensities, stress induces oscillations in the nucleocytoplasmic shuttling of the transcription factor Msn2 in budding yeast. Activation by stress results in a reversible translocation of Msn2 from the cytoplasm to the nucleus. This translocation is negatively controlled by the cAMP-PKA pathway through Msn2 phosphorylation. Here we show that the nuclear localization signal (NLS) of Msn2 is necessary and sufficient to promote the nucleocytoplasmic oscillations of the transcription factor. Because the NLS is controlled by protein kinase A (PKA) phosphorylation, we use a computational model to investigate the possibility that the cAMP-PKA pathway could function as an oscillator driving the periodic shuttling of Msn2. The model indicates that sustained oscillations of cAMP can indeed occur in a range bounded by two critical values of stress intensity, owing to the negative feedback exerted by PKA on cAMP accumulation. We verify the predictions of the model in mutants by showing that suppressing this negative-feedback loop prevents the oscillatory shuttling but still promotes the stress-induced nuclear localization of Msn2. The physiological significance of Msn2 oscillations is discussed in the light of the frequency encoding of cellular rhythms.