zeroclickinfo-goodies/share/goodie/crontab_cheat_sheet/crontab_cheat_sheet.html

76 lines
2.8 KiB
HTML

<style type="text/css">
.zci--answer .crontab-container {
max-height: 23.3ex;
overflow-y: auto;
}
.zci--answer .crontab-container .crontab-column {
width: 48%;
display: inline-block;
vertical-align:top;
}
.zci--answer .crontab-container .crontab-column:first-child {
margin-right: 3%;
}
.zci--answer .crontab-container p,
.zci--answer .crontab-container .crontab-column {
padding-top: 0;
padding-bottom: 2ex;
}
.zci--answer .crontab-container table {
width: 100%;
}
.zci--answer .crontab-container th {
font-weight: bold;
}
.zci--answer .crontab-container td {
vertical-align: top;
}
.zci--answer .crontab-container dd {
margin-bottom: 1ex;
}
@media(max-width: 704px) {
.zci--answer .crontab-container .crontab-column {
width: 100%;
margin-right: 0;
display: block;
}
}
</style>
<div class="crontab-container">
<div class="crontab-column">
<p>Commands are executed by cron when the minute, hour, and month
fields match the current time, and at least one of the two day fields
(day of month, or day of week) match the current time. A field may be
an asterisk (<code>*</code>), which will always match.</p>
<table>
<tr><th>Field</th><th>Allowed values</th>
<tr><td>minute</td><td>0-59</td></tr>
<tr><td>hour</td><td>0-23</td></tr>
<tr><td>day of month</td><td>1-31</td></tr>
<tr><td>month</td><td>1-12 or first three letters</td></tr>
<tr><td>day of week</td><td>0-7 or first three letters<br>(0 or 7 is Sunday)</td></tr>
</table>
</div>
<div class="crontab-column">
<b>Examples</b>
<dl>
<dt>Run every Tuesday at 2:30</dt>
<dd><code>30 2 * * tue /path/to/command</code></dd>
<dt>Run every 10 minutes</dt>
<dd><code>*/10 * * * * /path/to/command</code></dd>
<dt>Run every 2 hours, on the half hour</dt>
<dd><code>30 */2 * * * /path/to/command</code></dd>
<dt>Run every 2 hours, on the half hour, but only on weekdays</dt>
<dd><code>30 */2 * * 1-5 /path/to/command</code></dd>
<dt>Run at 12:05, 13:05, ..., and 18:05</dt>
<dd><code>5 12-18 * * * /path/to/command</code></dd>
<dt>Run at 12:05, 14:05, 16:05, and 18:05</dt>
<dd><code>5 12-18/2 * * * /path/to/command</code></dd>
<dt>Run on the first day of every month, at midnight</dt>
<dd><code>0 0 1 * * /path/to/command</code></dd>
<dt>Run on the first day of every third month, at midnight</dt>
<dd><code>0 0 1 */3 * /path/to/command</code></dd>
</dl>
</div>
</div>