cron
.
crone
is a simple utility which schedules tasks to be
run periodically at given times.
crone
differs from cron
in the following
ways:
crone
does not support multiple users.
Of course, individual users may run their own copies of crone
as desired.crone
is simply
started with a list of task descriptions. These could easily be stored
in a file to be read with file:consult/1
if desired.crone
launches, not system executables, but Erlang
functions. Of course, system programs can be launched with the Erlang
function os:cmd/1
.crontab
. It is (in this author's opinion) easier to read
and is much more in keeping with the Erlang tradition. It is not
quite as expressive as cron
but this can be compensated
for by adding multiple tasks.crone
does not poll the system on a minute-by-minute
basis like cron
does. Each task is assigned to a single
(Erlang) process. The time until it is to run next is calculated,
and the process sleeps for exactly that long.cron
's one-minute resolution, crone
has a 2-second resolution (actually 1 second, but after running the
task, the process waits an extra second to avoid accidentally running it
more than once.)crone
must be stopped and
restarted if the user wishes to change the scheduled tasks.crone
does not handle Daylight Savings Time (or other
cases when the system clock is altered) gracefully, and it is recommended
that it be stopped and restarted on such occasions.Exported Functions | |
---|---|
format_time/1 | Returns human-readable string from seconds past midnight. |
loop_task/1 | Used by start/1 to wait until the next time
each task is scheduled to run, run it, and repeat. |
start/1 | Starts crone , spawning a process for each task. |
stop/1 | Stops all monitoring processes started by crone . |
Internal Documented Functions | |
current_time/0 | Returns the current time, in seconds past midnight. |
first_time/1 | Calculates the first time in a given period. |
last_time/1 | Calculates the last time in a given period. |
next_time/2 | Calculates the first time in the given period after the given time. |
resolve_dow/1 | Returns the number of the given day of the week. |
resolve_dur/1 | Returns seconds for a given duration. |
resolve_period/1 | Returns a list of times given a periodic specification. |
resolve_time/1 | Returns seconds past midnight for a given time. |
run_task/1 | Spawns a process to accomplish the given task. |
until_days_from_now/2 | Calculates the duration in seconds until the given period occurs several days from now. |
until_next_daytime/1 | Calculates the duration in seconds until the next time this period is to occur during the day. |
until_next_daytime_or_days_from_now/2 | Calculates the duration in seconds until the given period occurs, which may be today or several days from now. |
until_next_time/1 | Calculates the duration in seconds until the next time a task is to be run. |
until_tomorrow/1 | Calculates the duration in seconds until the given time occurs tomorrow. |
format_time(integer()) -> string()
Returns human-readable string from seconds past midnight.
loop_task(task()) -> never_returns
Used by start/1
to wait until the next time
each task is scheduled to run, run it, and repeat.
start([task()]) -> [pid()]
Starts crone
, spawning a process for each task.
stop([task()]) -> ok
Stops all monitoring processes started by crone
.
current_time() -> seconds()
Returns the current time, in seconds past midnight.
first_time(period()) -> seconds()
Calculates the first time in a given period.
last_time(period()) -> seconds()
Calculates the last time in a given period.
next_time(period(), seconds()) -> seconds()
Calculates the first time in the given period after the given time.
resolve_dow(dow()) -> integer()
Returns the number of the given day of the week. See the calendar module for day numbers.
resolve_dur(duration()) -> seconds()
Returns seconds for a given duration.
resolve_period(period()) -> [seconds()]
Returns a list of times given a periodic specification.
resolve_time(time()) -> seconds()
Returns seconds past midnight for a given time.
run_task(task()) -> pid()
Spawns a process to accomplish the given task.
until_days_from_now(period(), integer()) -> seconds()
Calculates the duration in seconds until the given period occurs several days from now.
until_next_daytime(period()) -> seconds()
Calculates the duration in seconds until the next time this period is to occur during the day.
until_next_daytime_or_days_from_now(period(), integer()) -> seconds()
Calculates the duration in seconds until the given period occurs, which may be today or several days from now.
until_next_time(task()) -> seconds()
Calculates the duration in seconds until the next time a task is to be run.
until_tomorrow(seconds()) -> seconds()
Calculates the duration in seconds until the given time occurs tomorrow.