Current section
Files
Jump to
Current section
Files
doc/cloudi_cron.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Module cloudi_cron</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>
<h1>Module cloudi_cron</h1>
<ul class="index"><li><a href="#description">Description</a></li><li><a href="#types">Data Types</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>
<h3><a name="CloudI_Cron_Expression_Functionality">CloudI Cron Expression Functionality</a></h3>
The special character ? and the @reboot macro are not supported
because they wouldn't work well with Erlang process restarts.
<p>Copyright © 2019-2020 Michael Truog</p>
<p><b>Version:</b> 2.0.1 Nov 26 2020 17:53:26
------------------------------------------------------------------------</p>
<p><b>Authors:</b> Michael Truog (<a href="mailto:mjtruog at protonmail dot com"><tt>mjtruog at protonmail dot com</tt></a>).</p>
<h2><a name="description">Description</a></h2>
<h3><a name="CloudI_Cron_Expression_Functionality">CloudI Cron Expression Functionality</a></h3>
The special character ? and the @reboot macro are not supported
because they wouldn't work well with Erlang process restarts.
The other Cron expression syntax is implemented,
including the optional seconds and year values
(info from https://en.wikipedia.org/wiki/Cron#CRON_expression):
<pre> Field name Required Allowed values Allowed special characters
---------- -------- -------------- --------------------------
Seconds No 0-59 * / , -
Minutes Yes 0-59 * / , -
Hours Yes 0-23 * / , -
Day of month Yes 1-31 * / , - L W
Month Yes 1-12 or JAN-DEC * / , -
Day of week Yes 0-6 or SUN-SAT * / , - L #
Year No 1970–9999 * / , -</pre>
<h4><a name="Asterisk_(*)">Asterisk (*)</a></h4><p>
An asterisk indicates that the cron expression matches for all values
of the field.</p>
<h4><a name="Slash_(/)">Slash (/)</a></h4><p>
Slashes can be combined with ranges to specify step values.
For example, */5 in the minutes field indicates every 5 minutes.</p>
<h4><a name="Comma_(,)">Comma (,)</a></h4><p>
Commas are used to separate items of a list. For example,
using "MON,WED,FRI" in the day-of-week field means
Mondays, Wednesdays and Fridays.</p>
<h4><a name="Hyphen_(-)">Hyphen (-)</a></h4><p>
Hyphens define ranges. For example, 2000–2010 indicates every year
between 2000 and 2010, inclusive.</p>
<h4><a name="L">L</a></h4><p>
'L' stands for "last". When used in the day-of-week field, it allows you
to specify constructs such as "the last Friday" ("5L") of a given month.
In the day-of-month field, it specifies the last day of the month.</p>
<h4><a name="W">W</a></h4><p>
The 'W' character is allowed for the day-of-month field.
This character is used to specify the weekday (Monday-Friday) nearest
the given day. As an example, if you were to specify "15W" as the value
for the day-of-month field, the meaning is:
"the nearest weekday to the 15th of the month".
So, if the 15th is a Saturday, the trigger fires on Friday the 14th.
If the 15th is a Sunday, the trigger fires on Monday the 16th.
If the 15th is a Tuesday, then it fires on Tuesday the 15th.
However, if you specify "1W" as the value for day-of-month, and
the 1st is a Saturday, the trigger fires on Monday the 3rd,
as it does not 'jump' over the boundary of a month's days.</p>
<p>This implementation allows the W character to be used in a list.
For example, "1W,15W" is valid in the day-of-month field.</p>
<p>The W character can be combined with L as LW to mean
"the last business day of the month".</p>
<h4><a name="Hash_(#)">Hash (#)</a></h4><p>
'#' is allowed for the day-of-week field, and must be followed by
a number between one and five. It allows you to specify constructs such as
"the second Friday" of a given month. For example, entering "5#3" in the
day-of-week field corresponds to the third Friday of every month.</p>
<h4><a name="Other_Details">Other Details</a></h4>
<pre> * If only six fields are present,
a 0 second field is prepended
* If only five fields are present,
a 0 second field is prepended and a wildcard year field is appended
* The range for the day-of-week field is 0-7 instead of 0-6,
with 7 as Sunday (like 0) (BSD and ATT disagreed about this in the past)
* The month names are case-insensitive
* The day-of-week names are case-insensitive</pre>
<h2><a name="types">Data Types</a></h2>
<h3 class="typedecl"><a name="type-expression">expression()</a></h3>
<p><tt>expression() = {<a href="#type-field_seconds">field_seconds()</a>, <a href="#type-field_minutes">field_minutes()</a>, <a href="#type-field_hours">field_hours()</a>, <a href="#type-field_day_of_month">field_day_of_month()</a>, <a href="#type-field_month">field_month()</a>, <a href="#type-field_day_of_week">field_day_of_week()</a>, <a href="#type-field_year">field_year()</a>}</tt></p>
<h3 class="typedecl"><a name="type-expression_strings">expression_strings()</a></h3>
<p><tt>expression_strings() = {nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string()}</tt></p>
<h3 class="typedecl"><a name="type-field_day_of_month">field_day_of_month()</a></h3>
<p><tt>field_day_of_month() = [1..31 | last_day_of_month | {weekday, last_day_of_month | 1..31}, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_day_of_week">field_day_of_week()</a></h3>
<p><tt>field_day_of_week() = [0..6 | {last_day_of_week, 0..6} | {every, 1..5, 0..6}, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_hours">field_hours()</a></h3>
<p><tt>field_hours() = [0..23, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_minutes">field_minutes()</a></h3>
<p><tt>field_minutes() = [0..59, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_month">field_month()</a></h3>
<p><tt>field_month() = [1..12, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_seconds">field_seconds()</a></h3>
<p><tt>field_seconds() = [0..59, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-field_year">field_year()</a></h3>
<p><tt>field_year() = [1970..9999, ...] | undefined</tt></p>
<h3 class="typedecl"><a name="type-state">state()</a></h3>
<p><tt>state() = #cloudi_cron{expression_strings = <a href="#type-expression_strings">expression_strings()</a>, expression = <a href="#type-expression">expression()</a>}</tt></p>
<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#expression-1">expression/1</a></td><td>
<h4><a name="Provide_the_cron_expression_string.">Provide the cron expression string.</a></h4>.</td></tr>
<tr><td valign="top"><a href="#new-1">new/1</a></td><td>
<h4><a name="Create_a_parsed_representation_of_a_cron_expression.">Create a parsed representation of a cron expression.</a></h4>.</td></tr>
<tr><td valign="top"><a href="#next_datetime-2">next_datetime/2</a></td><td>
<h4><a name="Determine_the_next_datetime_based_on_the_cron_expression.">Determine the next datetime based on the cron expression.</a></h4>.</td></tr>
</table>
<h2><a name="functions">Function Details</a></h2>
<h3 class="function"><a name="expression-1">expression/1</a></h3>
<div class="spec">
<p><tt>expression(Cloudi_cron::<a href="#type-state">state()</a>) -> nonempty_string()</tt><br></p>
</div><p>
<h4><a name="Provide_the_cron_expression_string.">Provide the cron expression string.</a></h4>
</p>
<h3 class="function"><a name="new-1">new/1</a></h3>
<div class="spec">
<p><tt>new(Input::nonempty_string()) -> <a href="#type-state">state()</a></tt><br></p>
</div><p>
<h4><a name="Create_a_parsed_representation_of_a_cron_expression.">Create a parsed representation of a cron expression.</a></h4>
</p>
<h3 class="function"><a name="next_datetime-2">next_datetime/2</a></h3>
<div class="spec">
<p><tt>next_datetime(DateTime::<a href="calendar.html#type-datetime">calendar:datetime()</a>, Cloudi_cron::<a href="#type-state">state()</a>) -> <a href="calendar.html#type-datetime">calendar:datetime()</a> | undefined</tt><br></p>
</div><p>
<h4><a name="Determine_the_next_datetime_based_on_the_cron_expression.">Determine the next datetime based on the cron expression.</a></h4>
</p>
<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc</i></p>
</body>
</html>