Here is part of my CronJob spec:
kind: CronJob
spec:
schedule: #{service.schedule}
For a specific environment a cron job is set up, but I never want it to run. Can I write some value into schedule:
that will cause it to never run?
I haven't found any documentation for all supported syntax, but I am hoping for something like:
@never
or @InABillionYears
I think you can use @reboot,
see: https://en.wikipedia.org/wiki/Cron
@reboot configures a job to run once when the daemon is started. Since cron is typically never restarted, this typically corresponds to the machine being booted.
@reboot
doesn't guarantee that the job will never be run. It will actually be run always when your system is booted/rebooted and it may happen. It will be also run each time when cron daemon is restarted so you need to rely on that "typically it should not happen" on your system...
There are far more certain ways to ensure that a CronJob
will never be run:
.spec.suspend
field to true
You can easily set it using patch:
kubectl patch cronjobs <job-name> -p '{"spec" : {"suspend" : true }}'
day of the month
in relation to value set in a month
field. It just requires that you put valid numbers in both fields (1-31
and 1-12
respectively). You can set it to something like:* * 31 2 *
which for Cron is perfectly valid value but we know that such a date is impossible and it will never happen.
kind: CronJob
spec:
suspend: true