mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-23 07:57:39 +00:00
573 lines
19 KiB
HTML
573 lines
19 KiB
HTML
{% extends "base.html" %}
|
|
{% load compress hc_extras static %}
|
|
|
|
{% block title %}Cron Expression Syntax Cheatsheet - {{ site_name }}{% endblock %}
|
|
|
|
{% block description %}
|
|
<meta name="description" content="Visual examples of main Cron syntax features: numeric values, commas, ranges, ranges with step, day and month names.">
|
|
{% endblock %}
|
|
|
|
{% block keywords %}
|
|
<meta name="keywords" content="cron syntax, crontab syntax, cron howto, cron tutorial, cron jobs, cron job example, monitor cron jobs">
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
|
|
<h1>Cron Expression Syntax Cheatsheet</h1>
|
|
|
|
<p>
|
|
{{ site_name }} understands most of the traditional cron syntax features.
|
|
Under the hood, it uses the
|
|
<a href="https://github.com/cuu508/cronsim">cronsim package</a>
|
|
to parse and interpret cron expressions. Below is a showcase of
|
|
supported syntax features.
|
|
</p>
|
|
<p>
|
|
<strong>Pro-tip!</strong>
|
|
On Unix-like operating systems, you can also easily access cron syntax
|
|
documentation by typing <code>man 5 crontab</code> in shell.
|
|
</p>
|
|
<br />
|
|
|
|
<div id="cron-examples">
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Basics</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>A cron expression has five fields, separated by spaces.
|
|
Asterisk is a wild card character and means "any value."
|
|
</p>
|
|
|
|
<div class="desc">"Run every minute"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>* <span></span></div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>Day of week, 0 - 7, 0 or 7 is Sun</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
Month, 1 - 12
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3">
|
|
Day of month, 1 - 31
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4">
|
|
Hour of day, 0 - 23
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Minute, 0 - 59
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Numeric values</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>Use numeric values instead of asterisks to match specific
|
|
minutes, hours, days, and months.
|
|
</p>
|
|
|
|
<div class="desc">"Run at 6 PM on Fridays"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>0 <span></span></div></th>
|
|
<th><div>18</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>5</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>Run only on Fridays</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2" class="minor">
|
|
Run every month of the year
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3" class="minor">
|
|
Run every day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4">
|
|
Run at 6 PM
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Run at the start of the hour
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Commas</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>Use <code>{v1},{v2},...,{vn}</code> to list multiple values.</p>
|
|
|
|
<div class="desc">"Run at 9 AM, 12 PM, and 6 PM every day"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>0 <span></span></div></th>
|
|
<th><div>9,12,18</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td class="minor">Run on every weekday</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2" class="minor">
|
|
Run every month of the year
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3" class="minor">
|
|
Run every day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4">
|
|
Run at 9 AM, 12 PM and 6 PM
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Run at the start of the hour
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Ranges of values</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>Use <code>{start}-{end}</code> to define a range of matching values.</p>
|
|
|
|
<div class="desc">"Run every minute on workdays"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>* <span></span></div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>1-5</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>Run from Monday to Friday</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2" class="minor">
|
|
Run every month of the year
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3" class="minor">
|
|
Run every day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4" class="minor">
|
|
Run every hour of the day
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5" class="minor">
|
|
Run every minute of the hour
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Ranges with a step</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>Use <code>{start}-{end}/{step}</code> or <code>*/{step}</code>
|
|
to define a range with a step.</p>
|
|
|
|
<div class="desc">"Run every quarter of an hour"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>*/15 <span></span></div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td class="minor">Run on every weekday</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2" class="minor">
|
|
Run every month of the year
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3" class="minor">
|
|
Run every day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4" class="minor">
|
|
Run every hour of the day
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Run every 15 minutes
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Combine numeric values and ranges in lists</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>In the comma-separated lists, you can combine not only
|
|
numeric values but also ranges.</p>
|
|
|
|
<div class="desc">"Run every round hour outside office hours"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>0 <span></span></div></th>
|
|
<th><div>18-23,0-8</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>*</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td class="minor">Run on every weekday</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2" class="minor">
|
|
Run every month of the year
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3" class="minor">
|
|
Run every day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4">
|
|
Run at 6 PM, 7 PM, 8 PM, ..., 7 AM, 8 AM
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Run at the start of the hour
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Abbreviated day and month names</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p><code>JAN-DEC</code> can be used in the month field
|
|
and
|
|
<code>MON-SUN</code> in the weekday field.
|
|
</p>
|
|
|
|
<div class="desc">"Run every round hour on April 1st"</div>
|
|
|
|
<table class="cron-example">
|
|
<tr>
|
|
<th><div>0 <span></span></div></th>
|
|
<th><div>*</div></th>
|
|
<th><div>1</div></th>
|
|
<th><div>APR</div></th>
|
|
<th><div>*</div></th>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="5">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="4">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="3">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td rowspan="2">
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td>
|
|
<div class="guide"></div>
|
|
</td>
|
|
<td class="minor">Run on every weekday</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
Run in April
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="3">
|
|
Run on the first day of the month
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="4" class="minor">
|
|
Run every hour of the day
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
Run at the start of the hour
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title">Timezones</h3>
|
|
</div>
|
|
<div class="panel-body">
|
|
<p>
|
|
The cron daemon uses the server's <strong>local time</strong>.
|
|
If your server's timezone is other than UTC, make sure
|
|
to set a matching timezone for your check
|
|
on {{ site_name }} as well.
|
|
</p>
|
|
|
|
<p>On Ubuntu systems, you can check the server's timezone
|
|
with:</p>
|
|
<pre>cat /etc/timezone</pre>
|
|
</div>
|
|
</div>
|
|
</div> <!-- cron examples -->
|
|
|
|
<div id="test-area">
|
|
<h2>Cron Expression Tester</h2>
|
|
<p>Type or paste any cron expression:</p>
|
|
|
|
<input
|
|
id="schedule"
|
|
class="form-control input-lg"
|
|
type="text"
|
|
name=""
|
|
value="0 9,12,18 * * *"
|
|
autocomplete="off" />
|
|
{% csrf_token %}
|
|
|
|
|
|
<div id="cron-preview"></div>
|
|
|
|
<h2>Common Cron Expressions</h2>
|
|
|
|
<table id="common-cron-expressions" class="table">
|
|
<tr>
|
|
<td>Every minute</td>
|
|
<td>* * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 5 minutes</td>
|
|
<td>*/5 * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 15 minutes</td>
|
|
<td>*/15 * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 30 minutes</td>
|
|
<td>*/30 * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every hour</td>
|
|
<td>0 * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At 30 minutes past every hour</td>
|
|
<td>30 * * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 2 hours</td>
|
|
<td>0 */2 * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 3 hours</td>
|
|
<td>0 */3 * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Every 6 hours</td>
|
|
<td>0 */6 * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At 3 AM every day</td>
|
|
<td>0 3 * * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At 3 AM every Monday</td>
|
|
<td>0 3 * * MON</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At 8 AM, only on workdays</td>
|
|
<td>0 8 * * 1-5</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At the midnight of the first day of every month</td>
|
|
<td>0 0 1 * *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td>At the start of every third month</td>
|
|
<td>0 0 1 */3 *</td>
|
|
<td><button class="btn btn-default btn-sm">Test</button></td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
{% compress js %}
|
|
<script src="{% static 'js/docs_cron.js' %}"></script>
|
|
{% endcompress %}
|
|
{% endblock %} |