<p>I have a cronjob that should process events occurred since the last operation, for that I use DB to persist this timestamp, my question is whether or not it is possible to directly pass Kubernetes <strong>status.lastScheduleTime</strong> into the cronjob object as an environment variable? </p>

<p>I see the easiest way accomplish your goal via <code>kubectl set env</code> command, injecting into the particular <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">Cronjob</a> template object the desired <code>status.lastScheduleTime</code> field as <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/" rel="nofollow noreferrer">environment</a> variable <code>LAST_SCHEDULE</code>:</p>

<p><code>kubectl set env cronjob/name LAST_SCHEDULE=$(kubectl get cronjob name -o jsonpath='{.status.lastScheduleTime}')</code></p>

<pre><code>env:
- name: LAST_SCHEDULE
  value: "2019-09-23T08:56:00Z"
</code></pre>

<p>You may also find a more comprehensive way achieving <code>Cronjob</code> resource patching, supplying target environment variable  in the corresponded template with most recent <code>lastScheduleTime</code> value via <em><a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init Containers</a></em> or through <code>postStart</code>/<code>preStop</code> <em><a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers" rel="nofollow noreferrer">handlers</a></em>.</p>
