cron-daemon
A cron daemon/scheduler to perform tasks at fixed times, dates or intervals.
- Version
- 2
- Author
- Zooka
- Created
- 21 Oct 2024
- Updated
- 13 Aug 2026
Install from Mudlet's command line
mpkg install cron-daemonMudlet 4.20+ with mpkg installed
Description
Description
Cron Daemon is a script that schedules jobs (functions or actions) to be run periodically at fixed times, dates or intervals. It can schedule down to the nearest minute and as far out as once per year.
A job is a table that is passed to the cron monitor specifying when to execute a command.
The job daemon/monitor will wake up once per minute as the minute ticks over to execute any matching jobs. It relies on your operating system time for accuracy.
Wish to see further additions to this script? Consider supporting my efforts at https://buymeacoffee.com/zookaongit
Usage
cron help - to see this help
cron [list] - to see a list of scheduled jobs
Time Formats
hour (0..23)
minute (0..59)
day (1..31, of the month)
weekday (0..6, Sunday is 0)
month (1..12)
Times can contain ranges 1-3, enumerations 1-3,5,7 or * (every time).
e.g.
hour = "*" - match every hour
day = "1,10,20" - match 1st, 10th, 20th of each month only
weekday = "1-3" - match Monday, Tuesday, Wednesday only
month = "1,10-12" - match January, October, November, December only
Jobs must contain all time entries as mentioned above.
Jobs must match EVERY entry before they will fire (use * for always).
Job Commands
The command field is the function name to run without parenthesis.
Commands are specified in two common formats; command = functionName, command = function() send("look") end,
Cron functions in the first format do not accept arguments, use the second format to bring in variables for more elaborate jobs or multiple commands/functions.
ID
Used to identify a particular job, typically unique. Jobs can have the same name, but deleting one will delete only one of the jobs with the same ID.
Job Examples
-- perform myFunction() every minute
local job1 = { id = "my first job",
command = myFunction,
hour = "*",
minute = "*",
day = "*",
weekday = "*",
month = "*"
}
-- go to work at 8:15am, but only on weekdays
local job2 = { id = "off to work",
command = function()
echo("You'll be late for work!")
disconnect()
end,
hour = "8",
minute = "15",
day = "*",
weekday = "1-5",
month = "*"
}
-- Wishing you a happy birthday (at 10am, Jan 31st)
local job3 = { id = "birthday",
command = function()
echo("Happy Birthday!")
end,
hour = "10",
minute = "0",
day = "31",
weekday = "*",
month = "1"
}
-- add them to the scheduler
cron.add(job1)
cron.add(job2)
cron.add(job3)
-- delete them later
cron.delete("my first job")
-- or alternatively
cron.delete(job2.id)
Script (1)
Files (3)
38 KB unpacked
Select a script or file on the left to preview it here.