%%%---------------------------------------------------------------------- %%% %%% wg @copyright 2009 %%% %%% @author litao cheng %%% @doc the crontab record defines %%% %%%---------------------------------------------------------------------- -define(CRON_ANY, 1). % "*" -define(CRON_NUM, 2). % 2 -define(CRON_RANGE, 4). % 2-3 -define(CRON_LIST, 8). % "2,3-6" -type cronf_type() :: 1 | 2 | 4 | 8. -type cronf_num() :: non_neg_integer(). -type cronf_range() :: {non_neg_integer(), non_neg_integer(), pos_integer()}. -type cronf_list() :: [cronf_num() | cronf_range()]. -type cronf_value() :: cronf_num() | cronf_range() | cronf_list(). -record(cron_field, { type = ?CRON_ANY :: cronf_type(), % field type value :: cronf_value() % field value }). -type cron_field() :: #cron_field{}. -record(cron_entry, { m :: cron_field(), % minute h :: cron_field(), % hour dom :: cron_field(), % day of month mon :: cron_field(), % month dow :: cron_field(), % day of week mfa :: tuple() % the mfa }). -type cron_entry() :: #cron_entry{}. -define(CRON_FILE, "../ebin/data_crontab.beam"). -define(CRON_FILE_CLS, "../ebin/data_crontab_cls.beam"). -define(RELOAD_FILE_INTERVAL, 60000 * 60). % 1 hour -define(CHECK_FILE_INTERVAL, 60000). % 1 min -define(CHECK_CRON_INTERVAL, 60000). % 1 min -define(SERVER, ?MODULE). -record(crontab_state, { files =[], % file name file_activity :: list(), % activity file lists mtime = 0 :: pos_integer(), % last modify time entrys = [] :: [cron_entry()], % the cron tasks file_timer :: reference(), % the check file last modified timer cron_timer :: reference() % the check cron task timer }).