<p>Here is part of my CronJob spec:</p>

<pre><code>kind: CronJob
spec:
    schedule: #{service.schedule}
</code></pre>

<p>For a specific environment a cron job is set up, but I never want it to run. Can I write some value into <code>schedule:</code> that will cause it to never run?</p>

<p>I haven't found any documentation for all supported syntax, but I am hoping for something like:</p>

<p><code>@never</code> or <code>@InABillionYears</code></p>

user1283776
<p><code>@reboot</code> doesn't guarantee that the job will never be run. It will actually be run <strong>always when your system is booted/rebooted</strong> and <strong>it may happen</strong>. It will be also run <strong>each time when cron daemon is restarted</strong> so you need to rely on that <strong>"typically it should not happen"</strong> on your system...</p>

<p>There are far more certain ways to ensure that a <code>CronJob</code> will never be run:</p>

<ol>
<li><em>On Kubernetes level</em> by <a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#suspend" rel="noreferrer">suspending</a> a job by setting its <code>.spec.suspend</code> field to <code>true</code></li>
</ol>

<p>You can easily set it using patch:</p>

<pre><code>kubectl patch cronjobs &lt;job-name&gt; -p '{"spec" : {"suspend" : true }}'
</code></pre>

<ol start="2">
<li><em>On Cron level.</em> Use a trick based on fact that <strong>crontab</strong> syntax is not strictly validated and set a date that you can be sure will never happen like 31th of February. <strong>Cron</strong> will accept that as it doesn't check <code>day of the month</code> in relation to value set in a <code>month</code> field. It just requires that you put valid numbers in both fields (<code>1-31</code> and <code>1-12</code> respectively). You can set it to something like:</li>
</ol>

<p><code>* * 31 2 *</code></p>

<p>which for <strong>Cron</strong> is perfectly valid value but we know that such a date is impossible and it will never happen.</p>
