Change the LAST SCHEDULE date format on Kubernetes CronJob

3/15/2018

I'm reading the documentation and is not clear how change the format of the LAST-SCHEDULE date column. For me, is returning an approximation in hours (4h):

kubectl get cronjob job-one

NAME       SCHEDULE      SUSPEND   ACTIVE    LAST SCHEDULE   AGE
job-one    0 13 * * ?    False     0         4h              20d

But in the documentation the format is different, showing the date, time and timezone:

NAME      SCHEDULE      SUSPEND   ACTIVE    LAST-SCHEDULE
hello     */1 * * * *   False     0         Mon, 29 Aug 2016 14:34:00 -0700

How change the format of the LAST-SCHEDULE to return more information about the last schedule date?

Result of kubectl version client:

Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T21:07:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"windows/amd64"}
-- Dherik
kubernetes
kubernetes-cronjob

1 Answer

3/15/2018

I'm not sure how they have displayed that exact time format, but you can create custom columns for your kubectl output:

$ kubectl get cronjob job-one -o custom-columns=NAME:.metadata.name,LAST-SCHEDULE:.status.lastScheduleTime
NAME      LAST-SCHEDULE
job-one   2018-03-15T22:21:00Z
-- dippynark
Source: StackOverflow