In this paper we prove a commutative algebraic extension of a generalized Skolem–Mahler– Lech theorem. Let $A$ be a finitely generated commutative $K$–algebra over a field of characteristic 0, and let $\sigma$ be a $K$–algebra automorphism of $A$. Given ideals $I$ and $J$ of $A$, we show that the set $S$ of integers $m$ such that ${{\sigma }^{m}}(I)\,\supseteq \,J$ is a finite union of complete doubly infinite arithmetic progressions in $m$, up to the addition of a finite set. Alternatively, this result states that for an affine scheme $X$ of finite type over $K$, an automorphism $\sigma \,\in \,\text{Au}{{\text{t}}_{k}}(X)$, and $Y$ and $Z$ any two closed subschemes of $X$, the set of integers $m$ with ${{\sigma }^{m}}(Z)\,\subseteq \,Y$ is as above. We present examples showing that this result may fail to hold if the affine scheme $X$ is not of finite type, or if $X$ is of finite type but the field $K$ has positive characteristic.