<p>I'm working on a Kubernetes CronJob that relies on knowing when the last successfull run happened in order to correctly notify users about new events since said run. That said, I need to know if I can rely on <code>status.lastScheduleTime</code> to be my &quot;last successful run&quot; timestamp.</p>
<p>When does it change? Does it depend on exit codes? Is it even a good idea to use it for that purpose?</p>

<p>No, you can't rely on that as an indicator of a successful run. That value changes whenever your CronJob runs. It doesn't mean that it's your last successful run and it doesn't change depending on exit codes.</p>
<p>A <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer"><code>CronJob</code></a> essentially runs a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer"><code>Job</code></a> with a name that is <code>&lt;cronjob name&gt;-&lt;unix epoch&gt;</code>. The <a href="https://en.wikipedia.org/wiki/Unix_time" rel="nofollow noreferrer">epoch</a> is in Unix/Linux what you would get from the <code>date +%s</code> command, for example, also that epoch is a timestamp that is slightly later than the timestamp of the <code>lastScheduleTime</code> (It's when the job resource gets created)</p>
<p>To find out if your last cron job ran successfully you can do something like the following.</p>
<p>You can get the last Job run/started name including its epoch with something like this:</p>
<pre><code>$ kubectl get jobs | tail -1 | awk '{print $1}'
</code></pre>
<p>Then after that, you could check whether that job is successful with something like:</p>
<pre><code>$ kubectl get job &lt;job-name&gt; -o=jsonpath='{.status.succeeded}'
</code></pre>
<p>Should return a <code>1</code>.</p>
