2 YACRON - SIMPLE CRON PROGRAM
5 Originally written: 22 Aug 2009
9 This program was forked from the beautifully minimalist dcron v.3.2.
10 (Original REAMDE below.) I just needed it to be a bit less minimalist.
12 I had gotten to the point where I was juggling a combination of dcron,
13 a home-patched version of anacron, my own script to log job output
14 instead of mailing it, my own script to test for various conditions
15 (on A/C? have a network?) before running most jobs, and I _still_ couldn't
16 get the ensemble to do what I now needed. It was getting too baroque.
17 I had only ten or fifteen of my own cronjobs, but they were spread between
18 the root crontab, /etc/anacrontab, some /etc/cron.hourly/* scripts,
19 and where was all the beautiful minimalism now?
21 Probably I could get fcron <http://fcron.free.fr/> to do what I wanted, but
22 it looked so much more complex and heavier than I needed. I just wanted my
23 tools to be a _bit_ more capable.
25 So, since dcron has such a nice small codebase, I just took it and wrapped in
26 all I needed from anacron... plus the extra capabilities I was hankering for.
27 I've tried to retain the ideals of the original.
31 * can log to syslog or a file
33 * can email job output to a specified address, instead of the local user
36 * can replace sendmail with any other script to which all job output
39 * allows jobs to be scheduled on the "2nd and last" Mondays of a month
41 * accepts @daily, @reboot, etc. options in crontabs; @daily jobs
42 don't require the machine to be running at any specific time
44 * also accepts crontab lines with the format:
45 "* 2-6 * * * FREQ=2d/1h ID=<job_name> <command>"
46 this will try to run <command> once every 2 days, but only between the
47 hours of 2 and 6 am; if <command> exits with status EAGAIN it
48 will be retried again every 1 hour
50 * also accepts AFTER=<target_job>/1d assignments: if the specified
51 target_job is scheduled to run within the next 1 day, wait until
52 it has run and exited successfully before running the current command
54 COMPILATION, INSTALLATION, TESTING
58 BUG REPORTS, SUBMISSIONS
60 Jim Pryor profjim@jimpryor.net
64 ---------------------- Original README from dcron ----------------------
66 DCRON - SIMPLE CRON PROGRAM
69 Originally written: 1 May 1994
74 I finally got tired of all of these wild cron programs that take the
75 task of running timed jobs to ridiculous extremes in terms of
76 capabilities and unnecessary features. So here is my entry: a
77 crond/crontab combination that is simple and elegant, and hopefully
78 secure to boot. This cron implements reasonable features in terms
79 of field specification in the crontab and allows individual user
82 This program is written entirely from scratch by yours Truely (sig
85 All jobs are run with /bin/sh for conformity and portability, thereby
86 avoiding the mess that occurs with other cron's that try to use the
87 user's perfered shell, which breaks down for special users and even makes
88 some of us normal users unhappy (for example, /bin/csh does not use a true
89 O_APPEND mode and has difficulty redirecting stdout and stderr both to
90 different places!). You can, of course, run shell scripts in whatever
91 language you like by making them executable with #!/bin/csh or whatever
92 as the first line. If you don't like the extra processes, just 'exec'
95 Under the same reasoning, this cron does not allow you to specify
96 environment variables or other stuff better left specified as
97 arguments to a shell script. Talk about nonsense!
99 The programs were written with an eye towards security, hopefully I
100 haven't forgotton anything. The programs were also written with an
101 eye towards nice, clean, algorithmically sound code. It's small, and
102 the only fancy code is that which deals with child processes. I do
103 not try to optimize with vfork() since it causes headaches and is
104 rather pointless considering I'm execing a shell most of the time,
105 and I pay close attention to leaving descriptors open in the crond
106 and close attention to preventing crond from running away.
110 This is an ANSI program, you must use a compiler that understands
111 prototypes, such as GCC. I will not accept bug reports related
112 to hacking the program to work with a non-ANSI compiler.
114 Note that the source code, especially in regard to changing the
115 effective user, is Linux specific (SysVish). I welcome any changes
116 in regard to making the mechanism work with other platforms.
118 (1) Edit the Makefile, adding -D overrides to defines in defs.h as
119 appropriate for your machine. (Or just edit defs.h, but as
120 people introduce fixes to make the program work on other
121 platforms, I want most overrides to be in the CFLAGS for the
124 (2) You may need to edit the #include lines in defs.h for your
125 machine. The goal is to include everything necessary such that
126 the program can be compiled in the most ansi-strict manner. Amoung
127 other things, prototypes for system functions must come from
128 external include files and NOT from defs.h or any source file.
129 If no prototype exists for a particular function, contact your
130 vendor to get an update for your includes.
136 Permissions should be as outlined below. You will want to create a
137 special 'cron' group in which you put those users that are allowed
138 to use the crontab program.
140 -rwx------ 1 root wheel 24864 Apr 27 09:02 /usr/bin/crond*
141 -rwsr-x--- 1 root cron 24311 Apr 27 09:02 /usr/bin/crontab*
143 crond should be run automatically at system startup from /etc/rc.local
144 (or equivalent). It automatically detaches. A log level of 8 is
145 normally specified, and you normally append using /bin/sh's >>, allowing
146 the log file to backed up and cleared with an 'echo >/var/log/cron' in
149 /usr/bin/crond -l8 >>/var/log/cron 2>&1
151 The crontab files are normally located in /var/spool/cron/crontabs. The
152 directories normally have permissions:
154 drwxr-x--- 3 root wheel 1024 Feb 24 18:17 /var/spool/cron/
155 drwxr-x--- 2 root wheel 1024 May 1 10:28 /var/spool/cron/crontabs
159 Use the crontab program to create a personal crontab with the following
162 * * * * * date >>/tmp/test
165 Check the log output of crond to ensure the cron entries are being
166 run once a minute, check /tmp/test to ensure the date is being
167 appended to it once a minute, and check your mail to ensure that crond
168 is mailing you the date from the other entry once a minute.
170 After you are through testing cron, delete the entries with crontab -e
173 BUG REPORTS, SUBMISSIONS
175 Send any bug reports and source code changes to me, Matthew Dillon:
177 dillon@apollo.backplane.com
179 Note carefully that I will not accept any local ANSI prototypes for
180 system calls that should properly be in an external include file,
181 that I will probably not accept additional features to the program,
182 and I will not accept any changes to make the source compile under
183 a non-ANSI compiler. I will not accept any radical code changes...
184 the purpose being that I want this cron to be made bug free rather
187 Changes to overridable defaults in defs.h should be made in the
188 Makefile, you may submit a Makefile for your platform. Changes
189 to the #include's in defs.h should be made by a combination of an
190 -D options in the Makefile and #ifdef's for that option in defs.h,
191 and not rely on pre-definitions made by the C compiler.
193 Changes to source code to accomodate one platform or other should
194 be made in the same manner.
197 Matthew Dillon dillon@apollo.backplane.com
198 [always include a portion of the original email in any response!]