forked from GithubBackups/healthchecks
Cron syntax cheatsheet. Fixes #126
This commit is contained in:
parent
1232328aa9
commit
2d9563440e
@ -45,6 +45,7 @@ urlpatterns = [
|
||||
|
||||
url(r'^docs/$', views.docs, name="hc-docs"),
|
||||
url(r'^docs/api/$', views.docs_api, name="hc-docs-api"),
|
||||
url(r'^docs/cron/$', views.docs_cron, name="hc-docs-cron"),
|
||||
url(r'^about/$', views.about, name="hc-about"),
|
||||
url(r'^privacy/$', views.privacy, name="hc-privacy"),
|
||||
url(r'^terms/$', views.terms, name="hc-terms"),
|
||||
|
@ -139,6 +139,10 @@ def docs_api(request):
|
||||
|
||||
return render(request, "front/docs_api.html", ctx)
|
||||
|
||||
def docs_cron(request):
|
||||
ctx = {"page": "docs", "section": "cron"}
|
||||
return render(request, "front/docs_cron.html", ctx)
|
||||
|
||||
|
||||
def about(request):
|
||||
return render(request, "front/about.html", {"page": "about"})
|
||||
|
54
static/css/docs_cron.css
Normal file
54
static/css/docs_cron.css
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
|
||||
.cron-example th {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.cron-example th div {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-family: monospace;
|
||||
min-width: 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cron-example td {
|
||||
position: relative;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.cron-example .guide {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 50%;
|
||||
bottom: 15px;
|
||||
width: 40%;
|
||||
|
||||
border-left: 2px dotted #ddd;
|
||||
border-bottom: 2px dotted #ddd;
|
||||
}
|
||||
|
||||
.desc {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
font-size: 20px;
|
||||
color: #333;
|
||||
padding: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
#cron-examples {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#cron-examples .panel {
|
||||
width: 450px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.cron-example td.minor {
|
||||
color: #999;
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
<link rel="stylesheet" href="{% static 'css/snippet-copy.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/base.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/docs.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/docs_cron.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/welcome.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/my_checks.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/my_checks_mobile.css' %}" type="text/css">
|
||||
|
@ -19,6 +19,9 @@
|
||||
<li><a href="{% url 'hc-docs' %}#email">Email</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li {% if section == "cron" %} class="active" {% endif %}>
|
||||
<a href="{% url 'hc-docs-cron' %}">Cron Syntax</a>
|
||||
</li>
|
||||
<li {% if section == "api" %} class="active" {% endif %}>
|
||||
<a href="{% url 'hc-docs-api' %}">REST API</a>
|
||||
</li>
|
||||
|
@ -1,7 +1,11 @@
|
||||
{% load humanize tz %}
|
||||
|
||||
{% if bad_schedule %}
|
||||
<p id="invalid-arguments">Invalid cron expression</p>
|
||||
<p id="invalid-arguments">
|
||||
Invalid cron expression. <br />
|
||||
Please check the <a href="{% url 'hc-docs-cron' %}">supported cron syntax features</a>.
|
||||
|
||||
</p>
|
||||
{% elif bad_tz %}
|
||||
<p id="invalid-arguments">Invalid timezone</p>
|
||||
{% else %}
|
||||
|
530
templates/front/docs_cron.html
Normal file
530
templates/front/docs_cron.html
Normal file
@ -0,0 +1,530 @@
|
||||
{% extends "front/base_docs.html" %}
|
||||
{% load compress staticfiles hc_extras %}
|
||||
|
||||
{% block title %}Cron Syntax Cheatsheet - {% site_name %}{% endblock %}
|
||||
|
||||
{% block docs_content %}
|
||||
|
||||
<h2>Cron Syntax Cheatsheet</h2>
|
||||
|
||||
<p>
|
||||
{% site_name %} understands most of the traditional cron syntax features.
|
||||
Under the hood, it uses the
|
||||
<a href="https://github.com/taichino/croniter">croniter package</a>
|
||||
to parse and interpret cron expressions. Below is a showcase of
|
||||
supported syntax features.
|
||||
</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, 1=Monday</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 6PM 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 6PM
|
||||
</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 9AM, 12PM and 6PM 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 9AM, 12PM and 6PM
|
||||
</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 on 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}/{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>0/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, starting from minute 0
|
||||
</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 <code>{start}-{end}</code> and <code>{start}/{step}</code>
|
||||
constructs.</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 6PM, 7PM, 8PM, ..., 7AM, 8AM
|
||||
</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">First, second, ... weekday</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
Use <code>{day-of-week}#{n}</code> to define constructs
|
||||
such as "first Saturday of the month". <code>n</code> is a
|
||||
number from 1 to 5.
|
||||
</p>
|
||||
|
||||
<div class="desc">"Run at 2PM on the first Saturday
|
||||
<br />of every month"</div>
|
||||
|
||||
<table class="cron-example">
|
||||
<tr>
|
||||
<th><div>0 <span></span></div></th>
|
||||
<th><div>14</div></th>
|
||||
<th><div>*</div></th>
|
||||
<th><div>*</div></th>
|
||||
<th><div>6#1</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 on the first saturday of the month</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="minor">
|
||||
Run every month
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="minor">
|
||||
Run on any day of the month
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
Run at 2PM
|
||||
</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>
|
||||
Cron daemon uses 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 -->
|
||||
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user