-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncron.1
120 lines (116 loc) · 4.82 KB
/
ncron.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
.\" Man page for ncron
.\"
.\" Copyright (c) 2004-2024 Nicholas J. Kain
.\"
.TH ncron 1 "Feburary 9, 2024"
.LO 1
.SH NAME
ncron \- secure and reliable cron/at daemon
.SH SYNOPSIS
ncron [\-b0jqhv] [\-s msec] [\-c config_file] [\-t crontab_file]
[\-H history_file]
.SH DESCRIPTION
.B ncron
runs programs at intervals specified by the user, subject to time constraints.
It is designed to be both secure and reliable.
.SH OPTIONS
.TP
.B \-\^c , \-\-config=FILE
Specify the configuration file to use. Configuration file elements are
specified as key = value pairs, and correspond to long command line arguments.
.TP
.B \-\^t , \-\-crontab=FILE
Specify the crontab file to use; the default is
.BR /var/lib/ncron/crontab .
(See
.BR crontab (5).)
.TP
.B \-\^H , \-\-history=FILE
Specify the file in which ncron will store job
runtimes and the number of times that a job has
been invoked. The default location is
.BR /var/lib/ncron/exectime .
.TP
.B \-\^s , \-\-sleep=MSEC
Wait for the specified number of milliseconds at startup before running any
tasks. Useful for boot scripts that invoke ncron. Note that if ncron receives
a signal during this wait time, ncron will run pending jobs immediately.
.TP
.B \-\^0 \-\-noexecsave
Do not save any data on the times when jobs are executed.
.TP
.B \-\^j \-\-journal
Save execution times to disk immediately after a job is run. Perhaps useful
for very unstable machines that often suffer unclean shutdowns.
.TP
.B \-\^d \-\-s6-notify
Send a newline to the specified file descriptor when ncron begins to process
jobs; this is intended to be used as a service startup notification.
.TP
.BR \-\^h \-\-help
Print abbreviated help and exit.
.TP
.B \-\^v \-\-version
Print version information and exit.
.TP
.SH "INTRODUCTION"
.PP
ncron's job scheduling has two critical concepts: intervals and constraints. An
"interval" is simply the minimum time between job invocations. The concept of
time intervals is no doubt familiar. A trivial example of a simple interval
would be "wait one day before synchronizing my clock again". ncron intervals
are specified in seconds and have second precision.
.PP
Constraints limit the times in which a particular job may be run. In
ncron, intervals may be constrained by ranges of minutes, hours,
weekdays, days of the month, and months of the year. Multiple
constraint ranges may be applied, even of the same type. Constraints
of the same type will be mathematically unioned (logical OR'ed)
together. ncron internally uses a sieve-based algorithm to find the
smallest suitable time that satisfies the specified interval within
the specified constraint.
.PP
Examples are probably the clearest way of explaining this system. Suppose we
would like a locatedb to run weekly between 1 and 5am. Since we want the
program to run weekly, we would specify an interval of interval=7w. We would
then specify a constraint of time=1:00-5:00. ncron would then make sure that our job
only ran weekly between 1 and 5am.
.PP
The astute reader might wonder why ncron deals with constraints in terms of
intervals -- after all, if ncron uses a greedy algorithm, the task will only
run at a time other than the lower bound of the interval if the cron is invoked
at a time after the lower bound of the interval but within the interval. Why
bother with unnecessary complexity to handle that case? Traditional cronds
certainly don't bother. The answer lies in ncron's attempts to be reliable and
fast.
.PP
ncron internally works by precalculating the exact time at which a job
should be run. ncron then spends most of its time sleeping until its
next job, waking up only to handle signals. If ncron is gracefully
terminated, it will by default save these times it has
calculated. Thus, ncron keeps a memory of when jobs were invoked in
the past. This feature is obviously quite useful for systems that are
sometimes either suspended or shut down. For those who have very
critical jobs or very unstable computers, ncron can optionally save
these times to disk whenever they change in memory. This mode of
operation is called "journalling". Journal mode may be set either for
all jobs with a command-line flag, or for particular jobs in the
crontab file.
.PP
If it is necessary for regular users to run periodic background tasks, the
recommended method is to have the users run a per-user ncron. This is easily
possible by using the -c and -H options to specify user-specific crontab
and exectimes files. Tasks will then naturally run as that user.
.PP
For specifics on how to configure ncron, consult
.B crontab(5).
.SH ENVIRONMENT
ncron ignores its environment. It will pass through the environment which it
was provided when it was invoked. If a job is to be run with a custom shell
environment, a wrapper script should be used.
.SH "SEE ALSO"
crontab(5).
.SH BUGS
None known, otherwise they would be fixed.
.SH AUTHOR
Nicholas J. Kain <njkain (at) gmail.com>