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.
Creates a new schedule entry.
cron.schedule(mask, callback)
mask
- crontab-like string mask for schedulecallback
- callbackfunction(entry)
that is executed at the scheduled time
cron.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
- callbackfunction(entry)
that is executed at the scheduled time
nil
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 schedule
none
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()