diff --git a/hc/front/urls.py b/hc/front/urls.py index 23553286..5e3f5fbe 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -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"), diff --git a/hc/front/views.py b/hc/front/views.py index e212fa2b..81825015 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -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"}) diff --git a/static/css/docs_cron.css b/static/css/docs_cron.css new file mode 100644 index 00000000..b318da8e --- /dev/null +++ b/static/css/docs_cron.css @@ -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; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index cc0a2294..a4ee80f6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,6 +20,7 @@ + diff --git a/templates/front/base_docs.html b/templates/front/base_docs.html index a57fee22..8490d46b 100644 --- a/templates/front/base_docs.html +++ b/templates/front/base_docs.html @@ -19,6 +19,9 @@
Invalid cron expression
+
+ Invalid cron expression.
+ Please check the supported cron syntax features.
+
+
Invalid timezone
{% else %} diff --git a/templates/front/docs_cron.html b/templates/front/docs_cron.html new file mode 100644 index 00000000..25f99957 --- /dev/null +++ b/templates/front/docs_cron.html @@ -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 %} + ++ {% site_name %} understands most of the traditional cron syntax features. + Under the hood, it uses the + croniter package + to parse and interpret cron expressions. Below is a showcase of + supported syntax features. +
+ +A cron expression has five fields, separated by spaces. + Asterisk is a wild card character and means "any value". +
+ +* |
+ * |
+ * |
+ * |
+ * |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Day of week, 0 - 7, 1=Monday | +
+ Month, 1 - 12 + | +|||||
+ Day of month, 1 - 31 + | +|||||
+ Hour of day, 0 - 23 + | +|||||
+ Minute, 0 - 59 + | +
Use numeric values instead of asterisks to match specific + minutes, hours, days and months. +
+ +0 |
+ 18 |
+ * |
+ * |
+ 5 |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run only on Fridays | +
+ Run every month of the year + | +|||||
+ Run every day of the month + | +|||||
+ Run at 6PM + | +|||||
+ Run at the start of the hour + | +
Use {v1},{v2},...,{vn}
to list multiple values.
0 |
+ 9,12,18 |
+ * |
+ * |
+ * |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on every weekday | +
+ Run every month of the year + | +|||||
+ Run every day of the month + | +|||||
+ Run at 9AM, 12PM and 6PM + | +|||||
+ Run at the start of the hour + | +
Use {start}-{end}
to define a range of matching values.
* |
+ * |
+ * |
+ * |
+ 1-5 |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on Monday to Friday | +
+ Run every month of the year + | +|||||
+ Run every day of the month + | +|||||
+ Run every hour of the day + | +|||||
+ Run every minute of the hour + | +
Use {start}/{step}
to define a range with a step.
0/15 |
+ * |
+ * |
+ * |
+ * |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on every weekday | +
+ Run every month of the year + | +|||||
+ Run every day of the month + | +|||||
+ Run every hour of the day + | +|||||
+ Run every 15 minutes, starting from minute 0 + | +
In the comma-separated lists you can combine not only
+ numeric values but also {start}-{end}
and {start}/{step}
+ constructs.
0 |
+ 18-23,0-8 |
+ * |
+ * |
+ * |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on every weekday | +
+ Run every month of the year + | +|||||
+ Run every day of the month + | +|||||
+ Run at 6PM, 7PM, 8PM, ..., 7AM, 8AM + | +|||||
+ Run at the start of the hour + | +
JAN-DEC
can be used in the month field
+ and
+ MON-SUN
in the weekday field.
+
0 |
+ * |
+ 1 |
+ APR |
+ * |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on every weekday | +
+ Run in April + | +|||||
+ Run on the first day of the month + | +|||||
+ Run every hour of the day + | +|||||
+ Run at the start of the hour + | +
+ Use {day-of-week}#{n}
to define constructs
+ such as "first Saturday of the month". n
is a
+ number from 1 to 5.
+
0 |
+ 14 |
+ * |
+ * |
+ 6#1 |
+ |
---|---|---|---|---|---|
+ + | ++ + | ++ + | ++ + | ++ + | +Run on the first saturday of the month | +
+ Run every month + | +|||||
+ Run on any day of the month + | +|||||
+ Run at 2PM + | +|||||
+ Run at the start of the hour + | +
+ Cron daemon uses server's local time. + If your server's timezone is other than UTC, make sure + to set a matching timezone for your check + on {% site_name %} as well. +
+ +On Ubuntu systems you can check the server's timezone + with:
+cat /etc/timezone+