diff options
author | Kim Alvefur <zash@zash.se> | 2021-12-03 00:11:31 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-12-03 00:11:31 +0100 |
commit | 6f3409f3f24c3f1d73ef255a622d6c2251f2bd42 (patch) | |
tree | b944ec7ecb47ec8097b7bafa52544a6c468b5bfa /teal-src/plugins | |
parent | 82f6358657d85762ece207a1ff9aba18150f22f3 (diff) | |
download | prosody-6f3409f3f24c3f1d73ef255a622d6c2251f2bd42.tar.gz prosody-6f3409f3f24c3f1d73ef255a622d6c2251f2bd42.zip |
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.
Diffstat (limited to 'teal-src/plugins')
-rw-r--r-- | teal-src/plugins/mod_cron.tl | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/teal-src/plugins/mod_cron.tl b/teal-src/plugins/mod_cron.tl index fc9e9934..078869a9 100644 --- a/teal-src/plugins/mod_cron.tl +++ b/teal-src/plugins/mod_cron.tl @@ -54,6 +54,11 @@ function module.add_host(host_module : moduleapi) 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 + -- initialize daily tasks to run at ~midnight UTC for now + local now = os.time(); + task.last = now - now % 86400; + end return true; end |