I have a cronjob that runs every day. I’m looking for a cli way to delete only the next execution without changing the schedule code. E.g a cronjob runs every day at midnight. I need to delete tomorrow execution but keep all other executions (Tue, Wed, ..). Is there a way? I’ve read it is possible to suspend a cronjob but it seems this suspend all executions
CodePudding user response:
kubectl gives you several different ways to update running configurations. The main ways are the apply, edit, and patch commands.
In this case you can use the kubectl patch
command which allows you to change running configurations immediately.
You can run kubectl patch to add .spec.suspend: true
to the cron job,then sleep 86400
From above we can suspend the cron job for 24 hrs
Please refer to this spec.suspend field and set it to true for more information
After that we have to disable it or it will delay for another 24 hrs and the cycle repeats. For re-enable, we should run the kubectl patch
again to add .spec.suspend: false