Module ecron

Data Types

crontab()

crontab() = #{second => '*' | [0..59 | {0..58, 1..59}, ...], minute => '*' | [0..59 | {0..58, 1..59}, ...], hour => '*' | [0..23, ...], month => '*' | [1..12 | {1..11, 2..12}, ...], day_of_month => '*' | [1..31 | {1..30, 2..31}, ...], day_of_week => '*' | [0..6 | {0..5, 1..6}, ...]}

crontab_spec()

crontab_spec() = crontab() | string() | binary() | 1..4294967

ecron()

ecron() = #{name => name(), crontab => crontab(), start_time => calendar:rfc3339_string() | unlimited, end_time => calendar:rfc3339_string() | unlimited, mfa => mfargs(), type => cron | every}

end_datetime()

end_datetime() = unlimited | calendar:datetime()

mfargs()

mfargs() = {M::module(), F::atom(), A::[term()]}

name()

name() = term()

option()

option() = {singleton, boolean()} | {max_count, pos_integer() | unlimited}

options()

options() = [option()]

parse_error()

parse_error() = invalid_time | invalid_spec | month | day_of_month | day_of_week | hour | minute | second

start_datetime()

start_datetime() = unlimited | calendar:datetime()

statistic()

statistic() = #{ecron => ecron(), status => status(), failed => non_neg_integer(), ok => non_neg_integer(), results => [term()], run_microsecond => [pos_integer()], time_zone => local | utc, worker => pid(), next => [calendar:datetime()]}

status()

status() = deactivate | activate

Function Index

activate/1 activate an exist job, if the job is nonexistent, return {error, not_found}.
add/3Equivalent to add(JobName, Spec, MFA, unlimited, unlimited, []).
add/6 Add new crontab job.
add_with_count/3Equivalent to add_with_count(make_ref(), Spec, MFA, RunCount).
add_with_count/4Equivalent to add(make_ref(), Spec, MFA, unlimited, unlimited, [{max_count, RunCount}]).
add_with_datetime/4Equivalent to add(make_ref(), Spec, MFA, Start, End, []).
add_with_datetime/5Equivalent to add(JobName, Spec, MFA, Start, End, []).
deactivate/1 deactivate an exist job, if the job is nonexistent, return {error, not_found}.
delete/1 Delete an exist job, if the job is nonexistent, nothing happened.
parse_spec/2 parse a crontab spec with next trigger time.
reload/0 reload task manually, such as you should reload manually when the system time has alter a lot.
send_after/3 Starts a timer which will send the message Msg to Dest when crontab is triggered.
send_interval/3Equivalent to send_interval(make_ref(), Spec, Pid, Message, unlimited, unlimited, []).
send_interval/5Equivalent to send_interval(make_ref(), Spec, self(), Message, Start, End, Option).
send_interval/7 Evaluates Pid !
statistic/0 Statistic for all jobs.
statistic/1 Statistic from an exist job.

Function Details

activate/1

activate(JobName::name()) -> ok | {error, not_found}

activate an exist job, if the job is nonexistent, return {error, not_found}. if the job is already activate, nothing happened. the same effect as reinstall the job from now on.

add/3

add(JobName::name(), Spec::crontab_spec(), MFA::mfargs()) -> {ok, name()} | {error, parse_error(), term()} | {error, already_exist}

Equivalent to add(JobName, Spec, MFA, unlimited, unlimited, []).

add/6

add(JobName::name(), Spec::crontab_spec(), MFA::mfargs(), Start::start_datetime(), End::end_datetime(), Option::options()) -> {ok, name()} | {error, parse_error(), term()} | {error, already_exist}

Add new crontab job. All jobs that exceed the limit will be automatically removed.

add_with_count/3

add_with_count(Spec::crontab_spec(), MFA::mfargs(), RunCount::pos_integer()) -> {ok, name()} | {error, parse_error(), term()}

Equivalent to add_with_count(make_ref(), Spec, MFA, RunCount).

add_with_count/4

add_with_count(JobName::name(), Spec::crontab_spec(), MFA::mfargs(), RunCount::pos_integer()) -> {ok, name()} | {error, parse_error(), term()}

Equivalent to add(make_ref(), Spec, MFA, unlimited, unlimited, [{max_count, RunCount}]).

add_with_datetime/4

add_with_datetime(Spec::crontab_spec(), MFA::mfargs(), Start::start_datetime(), End::end_datetime()) -> {ok, name()} | {error, parse_error(), term()}

Equivalent to add(make_ref(), Spec, MFA, Start, End, []).

add_with_datetime/5

add_with_datetime(JobName::name(), Spec::crontab_spec(), MFA::mfargs(), Start::start_datetime(), End::end_datetime()) -> {ok, name()} | {error, parse_error(), term()} | {error, already_exist}

Equivalent to add(JobName, Spec, MFA, Start, End, []).

deactivate/1

deactivate(JobName::name()) -> ok | {error, not_found}

deactivate an exist job, if the job is nonexistent, return {error, not_found}. just freeze the job, use @see activate/1 to unfreeze job.

delete/1

delete(JobName::name()) -> ok

Delete an exist job, if the job is nonexistent, nothing happened.

parse_spec/2

parse_spec(Spec::crontab_spec(), Num::pos_integer()) -> {ok, #{type => cron | every, crontab => crontab_spec(), next => [calendar:rfc3339_string()]}} | {error, atom(), term()}

parse a crontab spec with next trigger time. For debug.

reload/0

reload() -> ok

reload task manually, such as you should reload manually when the system time has alter a lot.

send_after/3

send_after(Spec::crontab_spec(), Pid::pid() | atom(), Message::term()) -> {ok, reference()} | {error, parse_error(), term()}

Starts a timer which will send the message Msg to Dest when crontab is triggered.

send_interval/3

send_interval(Spec::crontab_spec(), Pid::pid(), Message::term()) -> {ok, name()} | {error, parse_error(), term()}

Equivalent to send_interval(make_ref(), Spec, Pid, Message, unlimited, unlimited, []).

send_interval/5

send_interval(Spec::crontab_spec(), Message::term(), Start::start_datetime(), End::end_datetime(), Option::options()) -> {ok, name()} | {error, parse_error(), term()} | {error, already_exist}

Equivalent to send_interval(make_ref(), Spec, self(), Message, Start, End, Option).

send_interval/7

send_interval(JobName::name(), Spec::crontab_spec(), Pid::pid(), Message::term(), Start::start_datetime(), End::end_datetime(), Option::options()) -> {ok, name()} | {error, parse_error(), term()} | {error, already_exist}

Evaluates Pid ! Message repeatedly when crontab is triggered. (Pid can also be an atom of a registered name.)

statistic/0

statistic() -> [statistic()]

Statistic for all jobs.

statistic/1

statistic(JobName::name()) -> {ok, statistic()} | {error, not_found}

Statistic from an exist job. if the job is nonexistent, return {error, not_found}.


Generated by EDoc