Ultracron is a simple job scheduler based on the excellent later module. Ultracron adds some basic job management utilities, syntactic sugar, and monitoring tools.
ultracron.add('test-job', ultracron.schedule.text('every 5 min'), function(done) {
console.log('I get called every five minutes!');
done();
});
Later supports all kinds of schedule definitions. (ultracron.schedule == later.parse
)
Adds a job.
id
- a unique job id (string)schedule
- a later schedulefn
- the function to invoke. The job function receives a callback argument, which is used only for statistic reporting. The job function can also return a promise.
When true
, all jobs are added in the paused state. Useful for development/testing/debugging.
Removes job id
.
Pauses job id
. Paused jobs will not be invoked on their regular schedule. You can still invoke a paused job manually.
Resumes job id
. The job will not be invoked immediately; it will run on its next scheduled occurrence.
Modifies the schedule of existing job id
.
opts.schedule
- something parseable by the text parser.
Immediately invokes job id
.
Ultracron will open port
and listen for connections from the monitoring tool. There's absolutely no security, so don't open this port to the world.
Ulracron includes a command-line tool for monitoring the status of your job scheduler.
When you npm install -g ultracron
, npm adds a ucmon
command. The monitor shows you the run/fail count, last run time, and next scheduled run time of each job.
You can also type some commands:
pause <jobspec>
- pauses job(s)resume <jobspec>
- un-pauses job(s)run <jobspec>
- immediately invokes job(s)abs
- shows last/next run time as absolute time (ie "3/9 12:34p")rel
- shows last/next run time as relative time (ie "in 5 minutes")sched <jobspec> <schedule>
- changes a job's schedulequit
<jobspec>
is a regex that matches one or more job IDs.
ucmon
also takes some optional arguments:
-h
,--host
- host to connect to. Default 127.0.0.1.-p
,--port
- port to connect to. Default 3010.