aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-11-30 11:38:59 +0000
committerMatthew Wild <mwild1@gmail.com>2023-11-30 11:38:59 +0000
commit2524736225df2654f99f0de3aaa638428d7c9980 (patch)
tree8472190116b8301c1a441101615e9a633a082b2a /plugins
parent82e46a35f56f366f3def079c250a35bf57b44c9f (diff)
downloadprosody-2524736225df2654f99f0de3aaa638428d7c9980.tar.gz
prosody-2524736225df2654f99f0de3aaa638428d7c9980.zip
mod_cron: Add shell command to list registered cron tasks with status
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_cron.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/mod_cron.lua b/plugins/mod_cron.lua
index 3b9838ec..cff7b4df 100644
--- a/plugins/mod_cron.lua
+++ b/plugins/mod_cron.lua
@@ -75,3 +75,31 @@ scheduled = module:add_timer(1, function()
module:log("debug", "Wait %ds", delay);
return delay
end);
+
+module:add_item("shell-command", {
+ section = "cron";
+ section_desc = "View and manage recurring tasks";
+ name = "tasks";
+ desc = "View registered tasks";
+ args = {};
+ handler = function (self, host)
+ local format_table = require "prosody.util.human.io".table;
+ local it = require "util.iterators";
+ local row = format_table({
+ { title = "Host", width = "2p" };
+ { title = "Task", width = "3p" };
+ { title = "Desc", width = "3p" };
+ { title = "When", width = "1p" };
+ { title = "Last run", width = "20" };
+ }, self.session.width);
+ local print = self.session.print;
+ print(row());
+ for host in it.sorted_pairs(host and { [host]=true } or active_hosts) do
+ for _, task in ipairs(module:context(host):get_host_items("task")) do
+ print(row { host, task.id, task.name, task.when, task.last and os.date("%Y-%m-%d %R:%S", task.last) or "never" });
+ --self.session.print(require "util.serialization".serialize(task, "debug"));
+ --print("");
+ end
+ end
+ end;
+});