Diff

plugins/mod_cron.lua @ 11995:bbd3ac65640d

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.
author Kim Alvefur <zash@zash.se>
date Fri, 03 Dec 2021 00:11:31 +0100
parent 11986:3d5135e8a2a7
child 12000:00c57684cf20
line wrap: on
line diff
--- a/plugins/mod_cron.lua	Tue Nov 30 00:55:54 2021 +0100
+++ b/plugins/mod_cron.lua	Fri Dec 03 00:11:31 2021 +0100
@@ -21,6 +21,10 @@
 		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