forked from docs/doc-exports
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com> Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com> Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
38 lines
3.3 KiB
HTML
38 lines
3.3 KiB
HTML
<a name="cce_faq_00213"></a><a name="cce_faq_00213"></a>
|
|
|
|
<h1 class="topictitle1">What Should I Do If a Scheduled Task Cannot Be Restarted After Being Stopped for a Period of Time?</h1>
|
|
<div id="body1571052832789"><p id="cce_faq_00213__p7804131710512">If a scheduled task is stopped during running, before its restart, the system calculates the difference between the last time the task was successfully executed and the current time and compares the time difference with the scheduled task period multiplied by 100. If the time difference is greater than the period multiplied by 100, the scheduled task will not be triggered again. For details, see <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" target="_blank" rel="noopener noreferrer">CronJob Limitations</a>.</p>
|
|
<p id="cce_faq_00213__p1391522103610">For example, assume that a cron job is set to create a job every minute from 08:30:00 and the <strong id="cce_faq_00213__b14892114118159">startingDeadlineSeconds</strong> field is not set. If the cron job controller stops running from 08:29:00 to 10:21:00, the job will not be started because the time difference between 08:29:00 and 10:21:00. 00 exceeds 100 minutes, that is, the number of missed scheduling times exceeds 100 (in the example, a scheduling period is 1 minute).</p>
|
|
<p id="cce_faq_00213__p145134816324">If the <strong id="cce_faq_00213__b116155915162">startingDeadlineSeconds</strong> field is set, the controller calculates the number of missed jobs in the last <em id="cce_faq_00213__i139996175133">x</em> seconds (<em id="cce_faq_00213__i13243161616148">x</em> indicates the value of <strong id="cce_faq_00213__b9836202119167">startingDeadlineSeconds</strong>). For example, if <strong id="cce_faq_00213__b13445153413166">startingDeadlineSeconds</strong> is set to <strong id="cce_faq_00213__b59051218021">200</strong>, the controller counts the number of jobs missed in the last 200 seconds. In this case, if the cron job controller stops running from 08:29:00 to 10:21:00, the job will start again at 10:22:00, because only three scheduling requests are missed in the last 200 seconds (in the example, one scheduling period is 1 minute).</p>
|
|
<div class="section" id="cce_faq_00213__section18655541163314"><h4 class="sectiontitle">Solution</h4><p id="cce_faq_00213__p133416375509">Configure the <strong id="cce_faq_00213__b44888193411">startingDeadlineSeconds</strong> parameter in a cron job. This parameter can be created or modified only by using kubectl or APIs.</p>
|
|
<p id="cce_faq_00213__p179391127124314">Example YAML:</p>
|
|
<pre class="screen" id="cce_faq_00213__screen1812716198437">apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: hello
|
|
spec:
|
|
<strong id="cce_faq_00213__b93974347447">startingDeadlineSeconds: 200</strong>
|
|
schedule: "* * * * *"
|
|
jobTemplate:
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: hello
|
|
image: busybox:1.28
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- date; echo Hello
|
|
restartPolicy: OnFailure</pre>
|
|
<p id="cce_faq_00213__p17051159381">If you create a cron job again, you can temporarily avoid this issue.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_faq_00186.html">Others</a></div>
|
|
</div>
|
|
</div>
|
|
|