5 kx DCRON - DILLON'S LIGHTWEIGHT CRON DAEMON
5 kx ========================================
5 kx
5 kx This lightweight cron daemon aims to be simple and secure, with just enough
5 kx features to stay useful. It was written from scratch by Matt Dillon in 1994.
5 kx It's now developed and maintained by Jim Pryor.
5 kx
5 kx In the author's opinion, having to combine a cron daemon with another daemon
5 kx like anacron makes for too much complexity. So the goal is a simple cron daemon
5 kx that can also take over the central functions of anacron.
5 kx
5 kx Unlike other fatter cron daemons, though, this cron doesn't even try to manage
5 kx environment variables or act as a shell. All jobs are run with `/bin/sh` for
5 kx conformity and portability. We don't try to use the user's preferred shell:
5 kx that breaks down for special users and even makes some of us normal users
5 kx unhappy (for example, /bin/csh does not use a true O_APPEND mode and has
5 kx difficulty redirecting stdout and stderr both to different places!). You can,
5 kx of course, run shell scripts in whatever language you like by making them
5 kx executable with #!/bin/csh or whatever as the first line. If you don't like
5 kx the extra processes, just `exec` them.
5 kx
5 kx If you need to set special environment variables, pass them as arguments to a
5 kx script.
5 kx
5 kx The programs were written with an eye towards security, hopefully we haven't
5 kx forgotton anything. The programs were also written with an eye towards nice,
5 kx clean, algorithmically sound code. It's small, and the only fancy code is that
5 kx which deals with child processes. We do not try to optimize with vfork() since
5 kx it causes headaches and is rather pointless considering we're execing a shell
5 kx most of the time, and we pay close attention to leaving descriptors open in the
5 kx crond and close attention to preventing crond from running away.
5 kx
5 kx
5 kx DOWNLOADING
5 kx -----------
5 kx
5 kx The project is hosted at: <http://www.jimpryor.net/linux/dcron.html>.
5 kx
5 kx The latest version is 4.5, which can be downloaded here:
5 kx <http://www.jimpryor.net/linux/releases/dcron-4.5.tar.gz>.
5 kx
5 kx A public git repo is available at: <http://repo.or.cz/w/dcron.git>.
5 kx
5 kx
5 kx COMPILING
5 kx ---------
5 kx
5 kx You must use a compiler that understands prototypes, such as GCC.
5 kx
5 kx (1) The following compile-time defaults are configurable via
5 kx command-line assignments on the `make` line (they're shown here with
5 kx their default values):
5 kx
5 kx PREFIX=/usr/local # where files will ultimately be installed
5 kx SBINDIR = $(PREFIX)/sbin # where crond will be installed
5 kx BINDIR = $(PREFIX)/bin # where crontab will be installed
5 kx MANDIR = $(PREFIX)/share/man # where manpages will be installed
5 kx CRONTABS = /var/spool/cron/crontabs # default dir for per-user crontabs
5 kx CRONSTAMPS = /var/spool/cron/cronstamps # default dir
5 kx SCRONTABS = /etc/cron.d # default dir for system crontabs
5 kx
5 kx CRONTAB_GROUP = wheel # who's allowed to edit their own crontabs?
5 kx LOG_IDENT = crond # syslog uses facility LOG_CRON and this identity
5 kx TIMESTAMP_FMT = %b %e %H:%M:%S # used if LC_TIME unset and logging to file
5 kx
5 kx A few additional compile-time settings are defined in defs.h. If you find yourself
5 kx wanting to edit defs.h directly, try editing the DEFS line in the Makefile instead.
5 kx
5 kx (2) Run make with your desired settings. For example:
5 kx
5 kx make PREFIX=/usr CRONTAB_GROUP=users
5 kx
5 kx (3) If you're using the git version, you might also want to `make man`,
5 kx to be sure the manpages are updated. This requires
5 kx [pandoc](http://johnmacfarlane.net/pandoc/).
5 kx
5 kx
5 kx INSTALLING
5 kx ----------
5 kx
5 kx (4) `make install` installs the files underneath PREFIX (by default, /usr/local).
5 kx If you're packaging, you can supply a DESTDIR argument here:
5 kx
5 kx make DESTDIR=/path/to/your/package/root install
5 kx
5 kx Permissions will be as follows:
5 kx
5 kx -rwx------ 0 root root 32232 Jan 6 18:58 /usr/local/sbin/crond
5 kx -rwsr-x--- 0 root wheel 15288 Jan 6 18:58 /usr/local/bin/crontab
5 kx
5 kx Only users belonging to crontab's group (here "wheel") will be able to use it.
5 kx You may want to create a special "cron" group and assign crontab to it:
5 kx
5 kx groupadd cron
5 kx chgrp cron /usr/local/bin/crontab
5 kx chmod 4750 /usr/local/bin/crontab
5 kx
5 kx (If the group already exists, you can specify it by supplying CRONTAB_GROUP
5 kx to the `make` or `make install` commands.)
5 kx
5 kx Then add users to group "cron" when you want them to be able to install
5 kx or edit their own crontabs. The superuser is able to install crontabs for users
5 kx who don't have the privileges to edit their own.
5 kx
5 kx You should schedule crond to run automatically from system startup, using
5 kx /etc/rc.local or a similar mechanism. crond automatically detaches. By default
5 kx it logs all events <= loglevel NOTICE to syslog.
5 kx
5 kx The crontab files are normally located in /var/spool/cron/crontabs, and timestamps
5 kx are normally in /var/spool/cron/cronstamps. These directories normally have permissions:
5 kx
5 kx drwxr-xr-x 2 root root 4096 Jan 6 18:50 /var/spool/cron
5 kx drwxr-xr-x 1 root root 0 Jan 6 18:58 /var/spool/cron/crontabs
5 kx drwxr-xr-x 1 root root 0 Jan 6 18:58 /var/spool/cron/cronstamps/
5 kx
5 kx Here is the superuser's crontab, created using `sudo crontab -e`:
5 kx
5 kx -rw------- 0 root root 513 Jan 6 18:58 /var/spool/cron/crontabs/root
5 kx
5 kx TESTING
5 kx -------
5 kx
5 kx Use the crontab program to create a personal crontab with the following
5 kx two lines:
5 kx
5 kx * * * * * date >> /tmp/test
5 kx * * * * * date
5 kx
5 kx Check the log output of crond to ensure the cron entries are being
5 kx run once a minute, check /tmp/test to ensure the date is being
5 kx appended to it once a minute, and check your mail to ensure that crond
5 kx is mailing you the date from the other entry once a minute.
5 kx
5 kx After you are through testing cron, delete the entries with `crontab -e`
5 kx or `crontab -d`.
5 kx
5 kx EXTRAS
5 kx ------
5 kx
5 kx The following are included in the "extra" folder. None of them are installed
5 kx by `make install`:
5 kx
5 kx crond.rc
5 kx : This is an example rc script to start and stop crond. It could be placed in
5 kx /etc/rc.d or /etc/init.d in suitable systems.
5 kx
5 kx crond.conf
5 kx : This contains user-modifiable settings for crond.rc. The sample crond.rc
5 kx expects to source this file from /etc/conf.d/crond.
5 kx
5 kx run-cron
5 kx : This simple shell script is a bare-bones alternative to Debian's run-parts.
5 kx
5 kx root.crontab
5 kx : This is an example crontab to install for the root user, or to install
5 kx in /etc/cron.d. It runs any executable scripts located in the directories /etc/cron.hourly,
5 kx /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly at the appropriate times.
5 kx This example uses the run-cron script mentioned above, and relies on you to
5 kx create the /etc/cron.* directories.
5 kx
5 kx prune-cronstamps
5 kx : crond never removes any files from your cronstamps directory. If usernames
5 kx are abandoned, or cron job names are abandoned, unused files will accumulate
5 kx there. This simple cronjob will prune any cronstamp files older than three months.
5 kx It will run weekly if placed in /etc/cron.d.
5 kx
5 kx crond.logrotate
5 kx : This is an example to place in /etc/logrotate.d. This config file assumes you
5 kx run crond using -L /var/log/crond.log. If you run crond using syslog instead (the default),
5 kx you may prefer to configure the rotation of all your syslog-generated logs in a
5 kx single config file.
5 kx
5 kx crontab.vim
5 kx : This makes vim handle backup files in way that doesn't interfere with crontab's security
5 kx model.
5 kx
5 kx
5 kx BUG REPORTS, SUBMISSIONS
5 kx ------------------------
5 kx
5 kx Send any bug reports and source code changes to Jim Pryor:
5 kx <profjim@jimpryor.net>.
5 kx
5 kx We aim to keep this program simple, secure, and bug-free, in preference to
5 kx adding features. Those advanced features we have added recently (such as
5 kx @noauto, FREQ= and AFTER= tags, advanced cron.update parsing) fit naturally
5 kx into the existing codebase.
5 kx
5 kx Our goal is also to make this program compilable in as near to a C89-strict a
5 kx manner as possible. Less-portable features we're aware of are described in the
5 kx comments to defs.h. We'll reduce these dependencies as feasible. Do let us know
5 kx if any of them are an obstacle to using crond on your platform.
5 kx
5 kx Changes to defs.h, whether to override defaults or to accommodate your platform,
5 kx should be made by a combination of a -D option in the Makefile
5 kx and an #ifdef for that option in defs.h. Don't rely on pre-definitions made
5 kx by the C compiler.
5 kx
5 kx Prototypes for system functions should come from external include
5 kx files and NOT from defs.h or any source file. If no prototype exists for a
5 kx particular function, contact your vendor to get an update for your includes.
5 kx
5 kx Note that the source code, especially in regard to changing the
5 kx effective user, is Linux specific (SysVish). We welcome any changes
5 kx in regard to making the mechanism work with other platforms.
5 kx
5 kx
5 kx CREDITS
5 kx -------
5 kx
5 kx We use `concat`, a lightweight replacement for `asprintf`, in order to be more
5 kx portable. This was written by Solar Designer and is in the public domain. See
5 kx <http://www.openwall.com/popa3d/>.
5 kx