You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

470 lines
15 KiB

  1. {% extends "front/base_docs.html" %}
  2. {% load compress staticfiles hc_extras %}
  3. {% block title %}Cron Syntax Cheatsheet - {% site_name %}{% endblock %}
  4. {% block docs_content %}
  5. <h2>Cron Syntax Cheatsheet</h2>
  6. <p>
  7. {% site_name %} understands most of the traditional cron syntax features.
  8. Under the hood, it uses the
  9. <a href="https://github.com/taichino/croniter">croniter package</a>
  10. to parse and interpret cron expressions. Below is a showcase of
  11. supported syntax features.
  12. </p>
  13. <p>
  14. <strong>Pro-tip!</strong>
  15. On Unix-like operating systems, you can also easily access cron syntax
  16. documentation by typing <code>man 5 crontab</code> in shell.
  17. </p>
  18. <br />
  19. <div id="cron-examples">
  20. <div class="panel panel-default">
  21. <div class="panel-heading">
  22. <h3 class="panel-title">Basics</h3>
  23. </div>
  24. <div class="panel-body">
  25. <p>A cron expression has five fields, separated by spaces.
  26. Asterisk is a wild card character and means "any value".
  27. </p>
  28. <div class="desc">"Run every minute"</div>
  29. <table class="cron-example">
  30. <tr>
  31. <th><div>* <span></span></div></th>
  32. <th><div>*</div></th>
  33. <th><div>*</div></th>
  34. <th><div>*</div></th>
  35. <th><div>*</div></th>
  36. </tr>
  37. <tr>
  38. <td rowspan="5">
  39. <div class="guide"></div>
  40. </td>
  41. <td rowspan="4">
  42. <div class="guide"></div>
  43. </td>
  44. <td rowspan="3">
  45. <div class="guide"></div>
  46. </td>
  47. <td rowspan="2">
  48. <div class="guide"></div>
  49. </td>
  50. <td>
  51. <div class="guide"></div>
  52. </td>
  53. <td>Day of week, 0 - 7, 0 or 7 is Sun</td>
  54. </tr>
  55. <tr>
  56. <td colspan="2">
  57. Month, 1 - 12
  58. </td>
  59. </tr>
  60. <tr>
  61. <td colspan="3">
  62. Day of month, 1 - 31
  63. </td>
  64. </tr>
  65. <tr>
  66. <td colspan="4">
  67. Hour of day, 0 - 23
  68. </td>
  69. </tr>
  70. <tr>
  71. <td colspan="5">
  72. Minute, 0 - 59
  73. </td>
  74. </tr>
  75. </table>
  76. </div>
  77. </div>
  78. <div class="panel panel-default">
  79. <div class="panel-heading">
  80. <h3 class="panel-title">Numeric values</h3>
  81. </div>
  82. <div class="panel-body">
  83. <p>Use numeric values instead of asterisks to match specific
  84. minutes, hours, days and months.
  85. </p>
  86. <div class="desc">"Run at 6PM on Fridays"</div>
  87. <table class="cron-example">
  88. <tr>
  89. <th><div>0 <span></span></div></th>
  90. <th><div>18</div></th>
  91. <th><div>*</div></th>
  92. <th><div>*</div></th>
  93. <th><div>5</div></th>
  94. </tr>
  95. <tr>
  96. <td rowspan="5">
  97. <div class="guide"></div>
  98. </td>
  99. <td rowspan="4">
  100. <div class="guide"></div>
  101. </td>
  102. <td rowspan="3">
  103. <div class="guide"></div>
  104. </td>
  105. <td rowspan="2">
  106. <div class="guide"></div>
  107. </td>
  108. <td>
  109. <div class="guide"></div>
  110. </td>
  111. <td>Run only on Fridays</td>
  112. </tr>
  113. <tr>
  114. <td colspan="2" class="minor">
  115. Run every month of the year
  116. </td>
  117. </tr>
  118. <tr>
  119. <td colspan="3" class="minor">
  120. Run every day of the month
  121. </td>
  122. </tr>
  123. <tr>
  124. <td colspan="4">
  125. Run at 6PM
  126. </td>
  127. </tr>
  128. <tr>
  129. <td colspan="5">
  130. Run at the start of the hour
  131. </td>
  132. </tr>
  133. </table>
  134. </div>
  135. </div>
  136. <div class="panel panel-default">
  137. <div class="panel-heading">
  138. <h3 class="panel-title">Commas</h3>
  139. </div>
  140. <div class="panel-body">
  141. <p>Use <code>{v1},{v2},...,{vn}</code> to list multiple values.</p>
  142. <div class="desc">"Run at 9AM, 12PM and 6PM every day"</div>
  143. <table class="cron-example">
  144. <tr>
  145. <th><div>0 <span></span></div></th>
  146. <th><div>9,12,18</div></th>
  147. <th><div>*</div></th>
  148. <th><div>*</div></th>
  149. <th><div>*</div></th>
  150. </tr>
  151. <tr>
  152. <td rowspan="5">
  153. <div class="guide"></div>
  154. </td>
  155. <td rowspan="4">
  156. <div class="guide"></div>
  157. </td>
  158. <td rowspan="3">
  159. <div class="guide"></div>
  160. </td>
  161. <td rowspan="2">
  162. <div class="guide"></div>
  163. </td>
  164. <td>
  165. <div class="guide"></div>
  166. </td>
  167. <td class="minor">Run on every weekday</td>
  168. </tr>
  169. <tr>
  170. <td colspan="2" class="minor">
  171. Run every month of the year
  172. </td>
  173. </tr>
  174. <tr>
  175. <td colspan="3" class="minor">
  176. Run every day of the month
  177. </td>
  178. </tr>
  179. <tr>
  180. <td colspan="4">
  181. Run at 9AM, 12PM and 6PM
  182. </td>
  183. </tr>
  184. <tr>
  185. <td colspan="5">
  186. Run at the start of the hour
  187. </td>
  188. </tr>
  189. </table>
  190. </div>
  191. </div>
  192. <div class="panel panel-default">
  193. <div class="panel-heading">
  194. <h3 class="panel-title">Ranges of values</h3>
  195. </div>
  196. <div class="panel-body">
  197. <p>Use <code>{start}-{end}</code> to define a range of matching values.</p>
  198. <div class="desc">"Run every minute on workdays"</div>
  199. <table class="cron-example">
  200. <tr>
  201. <th><div>* <span></span></div></th>
  202. <th><div>*</div></th>
  203. <th><div>*</div></th>
  204. <th><div>*</div></th>
  205. <th><div>1-5</div></th>
  206. </tr>
  207. <tr>
  208. <td rowspan="5">
  209. <div class="guide"></div>
  210. </td>
  211. <td rowspan="4">
  212. <div class="guide"></div>
  213. </td>
  214. <td rowspan="3">
  215. <div class="guide"></div>
  216. </td>
  217. <td rowspan="2">
  218. <div class="guide"></div>
  219. </td>
  220. <td>
  221. <div class="guide"></div>
  222. </td>
  223. <td>Run on Monday to Friday</td>
  224. </tr>
  225. <tr>
  226. <td colspan="2" class="minor">
  227. Run every month of the year
  228. </td>
  229. </tr>
  230. <tr>
  231. <td colspan="3" class="minor">
  232. Run every day of the month
  233. </td>
  234. </tr>
  235. <tr>
  236. <td colspan="4" class="minor">
  237. Run every hour of the day
  238. </td>
  239. </tr>
  240. <tr>
  241. <td colspan="5" class="minor">
  242. Run every minute of the hour
  243. </td>
  244. </tr>
  245. </table>
  246. </div>
  247. </div>
  248. <div class="panel panel-default">
  249. <div class="panel-heading">
  250. <h3 class="panel-title">Ranges with a step</h3>
  251. </div>
  252. <div class="panel-body">
  253. <p>Use <code>{start}-{end}/{step}</code> or <code>*/{step}</code>
  254. to define a range with a step.</p>
  255. <div class="desc">"Run every quarter of an hour"</div>
  256. <table class="cron-example">
  257. <tr>
  258. <th><div>*/15 <span></span></div></th>
  259. <th><div>*</div></th>
  260. <th><div>*</div></th>
  261. <th><div>*</div></th>
  262. <th><div>*</div></th>
  263. </tr>
  264. <tr>
  265. <td rowspan="5">
  266. <div class="guide"></div>
  267. </td>
  268. <td rowspan="4">
  269. <div class="guide"></div>
  270. </td>
  271. <td rowspan="3">
  272. <div class="guide"></div>
  273. </td>
  274. <td rowspan="2">
  275. <div class="guide"></div>
  276. </td>
  277. <td>
  278. <div class="guide"></div>
  279. </td>
  280. <td class="minor">Run on every weekday</td>
  281. </tr>
  282. <tr>
  283. <td colspan="2" class="minor">
  284. Run every month of the year
  285. </td>
  286. </tr>
  287. <tr>
  288. <td colspan="3" class="minor">
  289. Run every day of the month
  290. </td>
  291. </tr>
  292. <tr>
  293. <td colspan="4" class="minor">
  294. Run every hour of the day
  295. </td>
  296. </tr>
  297. <tr>
  298. <td colspan="5">
  299. Run every 15 minutes
  300. </td>
  301. </tr>
  302. </table>
  303. </div>
  304. </div>
  305. <div class="panel panel-default">
  306. <div class="panel-heading">
  307. <h3 class="panel-title">Combine numeric values and ranges in lists</h3>
  308. </div>
  309. <div class="panel-body">
  310. <p>In the comma-separated lists you can combine not only
  311. numeric values but also ranges.</p>
  312. <div class="desc">"Run every round hour outside office hours"</div>
  313. <table class="cron-example">
  314. <tr>
  315. <th><div>0 <span></span></div></th>
  316. <th><div>18-23,0-8</div></th>
  317. <th><div>*</div></th>
  318. <th><div>*</div></th>
  319. <th><div>*</div></th>
  320. </tr>
  321. <tr>
  322. <td rowspan="5">
  323. <div class="guide"></div>
  324. </td>
  325. <td rowspan="4">
  326. <div class="guide"></div>
  327. </td>
  328. <td rowspan="3">
  329. <div class="guide"></div>
  330. </td>
  331. <td rowspan="2">
  332. <div class="guide"></div>
  333. </td>
  334. <td>
  335. <div class="guide"></div>
  336. </td>
  337. <td class="minor">Run on every weekday</td>
  338. </tr>
  339. <tr>
  340. <td colspan="2" class="minor">
  341. Run every month of the year
  342. </td>
  343. </tr>
  344. <tr>
  345. <td colspan="3" class="minor">
  346. Run every day of the month
  347. </td>
  348. </tr>
  349. <tr>
  350. <td colspan="4">
  351. Run at 6PM, 7PM, 8PM, ..., 7AM, 8AM
  352. </td>
  353. </tr>
  354. <tr>
  355. <td colspan="5">
  356. Run at the start of the hour
  357. </td>
  358. </tr>
  359. </table>
  360. </div>
  361. </div>
  362. <div class="panel panel-default">
  363. <div class="panel-heading">
  364. <h3 class="panel-title">Abbreviated day and month names</h3>
  365. </div>
  366. <div class="panel-body">
  367. <p><code>JAN-DEC</code> can be used in the month field
  368. and
  369. <code>MON-SUN</code> in the weekday field.
  370. </p>
  371. <div class="desc">"Run every round hour on April 1st"</div>
  372. <table class="cron-example">
  373. <tr>
  374. <th><div>0 <span></span></div></th>
  375. <th><div>*</div></th>
  376. <th><div>1</div></th>
  377. <th><div>APR</div></th>
  378. <th><div>*</div></th>
  379. </tr>
  380. <tr>
  381. <td rowspan="5">
  382. <div class="guide"></div>
  383. </td>
  384. <td rowspan="4">
  385. <div class="guide"></div>
  386. </td>
  387. <td rowspan="3">
  388. <div class="guide"></div>
  389. </td>
  390. <td rowspan="2">
  391. <div class="guide"></div>
  392. </td>
  393. <td>
  394. <div class="guide"></div>
  395. </td>
  396. <td class="minor">Run on every weekday</td>
  397. </tr>
  398. <tr>
  399. <td colspan="2">
  400. Run in April
  401. </td>
  402. </tr>
  403. <tr>
  404. <td colspan="3">
  405. Run on the first day of the month
  406. </td>
  407. </tr>
  408. <tr>
  409. <td colspan="4" class="minor">
  410. Run every hour of the day
  411. </td>
  412. </tr>
  413. <tr>
  414. <td colspan="5">
  415. Run at the start of the hour
  416. </td>
  417. </tr>
  418. </table>
  419. </div>
  420. </div>
  421. <div class="panel panel-default">
  422. <div class="panel-heading">
  423. <h3 class="panel-title">Timezones</h3>
  424. </div>
  425. <div class="panel-body">
  426. <p>
  427. Cron daemon uses server's <strong>local time</strong>.
  428. If your server's timezone is other than UTC, make sure
  429. to set a matching timezone for your check
  430. on {% site_name %} as well.
  431. </p>
  432. <p>On Ubuntu systems you can check the server's timezone
  433. with:</p>
  434. <pre>cat /etc/timezone</pre>
  435. </div>
  436. </div>
  437. </div> <!-- cron examples -->
  438. {% endblock %}