Home

nodecron

Nodecron, commonly referred to as node-cron, is a lightweight scheduling library for Node.js that enables running functions at times specified by cron expressions. It is designed to be simple and dependency-light, making it suitable for recurring tasks within a Node application, such as maintenance jobs, data synchronization, or report generation.

Overview and usage: The library exposes a schedule function that takes a cron expression, a callback, and

Expression support and behavior: Cron expressions are parsed to trigger the callback when the system time matches

Limitations and considerations: Precision depends on the Node process performance and clock accuracy. Time zone configuration

See also: Other cron-like schedulers for Node.js include node-schedule and Agenda.

an
optional
options
object.
The
invocation
returns
a
task
object
that
can
be
controlled
with
start,
stop,
and
destroy
methods.
Example:
const
cron
=
require('node-cron');
const
task
=
cron.schedule('*/5
*
*
*
*',
()
=>
{
doSomething();
},
{
timezone:
'UTC'
});
The
typical
cron
expression
follows
five
fields
(minute,
hour,
day
of
month,
month,
day
of
week);
some
implementations,
including
certain
versions
of
node-cron,
support
an
optional
seconds
field
as
well.
the
schedule.
The
scheduler
runs
inside
the
Node.js
event
loop
and
relies
on
the
process
remaining
active.
It
does
not
provide
persistence
across
restarts,
so
tasks
will
not
resume
after
a
server
reboot
unless
the
application
is
started
again
or
an
external
scheduler
is
used.
is
optional
and
varies
by
version.
Error
handling
in
callbacks
should
be
managed
to
avoid
stopping
the
scheduler,
and
long-running
tasks
can
delay
subsequent
schedules.