'How to reset k8s cronjob schedule?

Kubernetes have cronjob which can be used to schedule jobs periodically https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/

Is there a way to reset cronjob schedule, let's say it's running at 0,5,10,15th min of hour at every 5 mins schedule, now if i want to schedule a job manually at 17th min, i can trigger one, but i also want now cronjob schedule to reset and next run should be at 22th min, instead of 20th min.

I have tried deleting and recreating job with same spec, but that doesn't help as well, somehow it ends up restoring schedule meta for the job specs.

Is there a trick to reset cronjob schedule?

Cron job running at every 5 min

0, 5, 10, 15th, 20th

Reset at 17th mins , next cadence should be

0, 5, 10, 15th, 17th, 22th



Solution 1:[1]

Automatically no ( actually maybe with a script that modify your cronjob manifest but I think that's ugly but do whatever you want)

However, if you want to modify it after every manual job execution (for example at min 17) go modify your cronjob like this for example:

2-57/5 * * * * 

This way if you ran it manually a minute 17, the next will be 22,27 etc..

If another day you ran it manually at minute 24 for example do this:

4-59/5 * * * * 

Etc...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bguess