We examined the effects of different acute exercise durations and recovery periods on cognitive function in a counterbalanced, cross-over randomized controlled experiment. We placed 352 participants, aged 18 to 35 years into one of 16 experimental groups. Each participant visited the laboratory twice, separated by a 1-week washout period. Either Visit 1 or 2 consisted of an acute bout of moderate-intensity treadmill exercise (10, 20, 30, 45, or 60 minutes) followed by a period of rest (5, 15, or 30 minutes) before taking a set of five cognitive tests; the other visit consisted only of completing the cognitive tests (no exercise). Cognitive tests sampled multiple cognitive parameters, including reasoning, concentration, memory, attention, and planning. We found that a short recovery period (i.e., 5 minutes) may have a less favorable effect on planning ability but may be beneficial for memory. In addition, for various exercise durations and recovery periods, a Group × Time × Resting (nonexercise) A cognitive interaction effect was observed such that for both memory and inhibitory cognitive ability, acute exercise (vs. no exercise) had an enhancement effect for those with lower resting cognitive functioning. The length of the acute exercise recovery period and resting cognitive ability most influenced the association between exercise and cognitive function.