From 6f3409f3f24c3f1d73ef255a622d6c2251f2bd42 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 3 Dec 2021 00:11:31 +0100 Subject: mod_cron: Initialize daily tasks so they run around midnight UTC Eventually the goal is to have daily tasks run while there is little activity, but that will vary with the server and the usage patterns of its users. This is a start anyway. --- plugins/mod_cron.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_cron.lua b/plugins/mod_cron.lua index 257bf399..8d38c227 100644 --- a/plugins/mod_cron.lua +++ b/plugins/mod_cron.lua @@ -21,6 +21,10 @@ function module.add_host(host_module) task.save = save_task; module:log("debug", "%s task %s added, last run %s", task.when, task.id, task.last and require("util.datetime").datetime(task.last) or "never"); + if task.last == nil and task.when == "daily" then + local now = os.time(); + task.last = now - now % 86400; + end return true end -- cgit v1.2.3