The effect of aspect ratio on natural convection flow in a cavity submitted to periodic temperature boundary, is investigated numerically. The temperature of the heated wall is either maintained constant or varied sinusoidally with time while the temperature of the opposite vertical wall is maintained constant. The results are given for a range of varied parameters as Rayleigh number $(5\xd7103\u2a7dRa\u2a7d106)$, cavity aspect ratio $(1\u22156\u2a7dA\u2a7d8)$, and period of the sinusoidally heated wall $(1\u2a7d\tau \u2a7d1600)$. The amplitude of oscillation $(a=0.8)$ and the Prandtl number $(Pr=0.71)$ were kept constant. The results obtained in the steady state regime show that the heat transfer averaged over the cold wall is maximum when the aspect ratio is in the range $1\u2a7dA\u2a7d2$. In the case of a periodic temperature boundary, it is shown that the deviation between the mean heat transfer and the heat transfer of the constant heated case is larger for shallow cavities.