If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
The oc get cronjobs (or oc get cj) command can be used to list the cronjobs in the currently selected project / namespace.
TIP
The -A or --all-namespaces flag can be used to list the cronjobs in every project / namespace.
The -n or --namespace flag can be used to list the cronjobs in a certain project / namespace.
oc get cronjobs
If there are no cronjobs, something like this should be displayed.
No resources found in foo namespace.
On the other hand, if there are cronjobs, something like this should be displayed.
NAMESPACE NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
foo cj001 01 06 * * 1-6 False 0 21h 77d
Or you can list a single job in a namespace.
oc get cronjob/cj001 --namespace my-project
Or the -A or --all-namespaces flag can be used to list the cronjobs in all namespaces.
oc get cronjobs --all-namespaces
The -o yaml or -o json option can be used to display more details.
oc get job/myjob-1639634460 --output yaml --namespace my-project
Which should display something that begins like this.
apiVersion: batch/v1beta1
kind: Cronjob
metadata:
creationTimestamp: "2021-12-16T06:01:02Z"
labels:
name: cj001
The oc get jobs command may contain jobs that have been run.
~]$ oc get jobs --namespace my-project
NAME COMPLETIONS DURATION AGE
myjob-27960735 1/1 11s 110m
myjob-27960765 1/1 7s 80m
myjob-27960795 1/1 12s 50m
myjob-27960825 0/1 20m 20m
Did you find this article helpful?
If so, consider buying me a coffee over at