docs/modules/cron.md
| Since | Origin / Contributor | Maintainer | Source |
|---|---|---|---|
| 2016-12-18 | PhoeniX | PhoeniX | cron.c |
Cron-like scheduler module.
!!! important
This module needs RTC time to operate correctly. Do not forget to include the rtctime module and initialize it properly.
!!! important The cron expression has to be in GMT/UTC!
Creates a new schedule entry.
cron.schedule(mask, callback)
mask - crontab-like string mask for schedulecallback - callback function(entry) that is executed at the scheduled timecron.entry sub module
cron.schedule("* * * * *", function(e)
print("Every minute")
end)
cron.schedule("*/5 * * * *", function(e)
print("Every 5 minutes")
end)
cron.schedule("0 */2 * * *", function(e)
print("Every 2 hours")
end)
Removes all scheduled entries.
cron.reset()
none
nil
Sets a new handler for entry.
handler(callback)
callback - callback function(entry) that is executed at the scheduled timenil
ent = cron.schedule("* * * * *", function(e)
print("Every minute")
end)
ent:handler(function(e)
print("New handler: Every minute")
end)
Sets a new schedule mask.
schedule(mask)
mask - crontab-like string mask for schedulenone
ent = cron.schedule("* * * * *", function(e)
print("Tick")
end)
-- Every 5 minutes is really better!
ent:schedule("*/5 * * * *")
Disables schedule.
Disabled schedules may be enabled again by calling :schedule(mask).
unschedule()
none
nil
ent = cron.schedule("* * * * *", function(e)
print("Tick")
end)
-- We don't need this anymore
ent:unschedule()