xref: /dflybsd-src/usr.sbin/cron/doc/CONVERSION (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino$FreeBSD: src/usr.sbin/cron/doc/CONVERSION,v 1.4 1999/08/28 01:15:52 peter Exp $
2*86d7f5d3SJohn Marino$DragonFly: src/usr.sbin/cron/doc/CONVERSION,v 1.3 2004/01/08 18:39:19 asmodai Exp $
3*86d7f5d3SJohn Marino
4*86d7f5d3SJohn MarinoConversion of BSD 4.[23] crontab files:
5*86d7f5d3SJohn Marino
6*86d7f5d3SJohn MarinoEdit your current crontab (/usr/lib/crontab) into little pieces, with each
7*86d7f5d3SJohn Marinousers' commands in a different file.  This is different on 4.2 and 4.3,
8*86d7f5d3SJohn Marinobut I'll get to that below.  The biggest feature of this cron is that you
9*86d7f5d3SJohn Marinocan move 'news' and 'uucp' cron commands into files owned and maintainable
10*86d7f5d3SJohn Marinoby those two users.  You also get to rip all the fancy 'su' footwork out
11*86d7f5d3SJohn Marinoof the cron commands.  On 4.3, there's no need for the 'su' stuff since the
12*86d7f5d3SJohn Marinouser name appears on each command -- but I'd still rather have separate
13*86d7f5d3SJohn Marinocrontabs with separate environments and so on.
14*86d7f5d3SJohn Marino
15*86d7f5d3SJohn MarinoLeave the original /usr/lib/crontab!  This cron doesn't use it, so you may
16*86d7f5d3SJohn Marinoas well keep it around for a while in case something goes wakko with this
17*86d7f5d3SJohn Marinofancy version.
18*86d7f5d3SJohn Marino
19*86d7f5d3SJohn MarinoMost commands in most crontabs are run by root, have to run by root, and
20*86d7f5d3SJohn Marinoshould continue to be run by root.  They still have to be in their own file;
21*86d7f5d3SJohn MarinoI recommend /etc/crontab.src or /usr/adm/crontab.src.
22*86d7f5d3SJohn Marino
23*86d7f5d3SJohn Marino'uucp's commands need their own file; how about /usr/lib/uucp/crontab.src?
24*86d7f5d3SJohn Marino'news' also, perhaps in /usr/lib/news/crontab.src...
25*86d7f5d3SJohn Marino
26*86d7f5d3SJohn MarinoI say `how about' and `perhaps' because it really doesn't matter to anyone
27*86d7f5d3SJohn Marino(except you) where you put the crontab source files.  The `crontab' command
28*86d7f5d3SJohn MarinoCOPIES them into a protected directory (CRONDIR/SPOOL_DIR in cron.h), named
29*86d7f5d3SJohn Marinoafter the user whose crontab it is.  If you want to examine, replace, or
30*86d7f5d3SJohn Marinodelete a crontab, the `crontab' command does all of those things.  The
31*86d7f5d3SJohn Marinovarious `crontab.src' (my suggested name for them) files are just source
32*86d7f5d3SJohn Marinofiles---they have to be copied to SPOOLDIR using `crontab' before they'll be
33*86d7f5d3SJohn Marinoexecuted.
34*86d7f5d3SJohn Marino
35*86d7f5d3SJohn MarinoOn 4.2, your crontab might have a few lines like this:
36*86d7f5d3SJohn Marino
37*86d7f5d3SJohn Marino	5 * * * *   su uucp < /usr/lib/uucp/uudemon.hr
38*86d7f5d3SJohn Marino	10 4 * * *  su uucp < /usr/lib/uucp/uudemon.day
39*86d7f5d3SJohn Marino	15 5 * * 0  su uucp < /usr/lib/uucp/uudemon.wk
40*86d7f5d3SJohn Marino
41*86d7f5d3SJohn Marino...or like this:
42*86d7f5d3SJohn Marino
43*86d7f5d3SJohn Marino	5 * * * *   echo /usr/lib/uucp/uudemon.hr | su uucp
44*86d7f5d3SJohn Marino	10 4 * * *  echo /usr/lib/uucp/uudemon.day | su uucp
45*86d7f5d3SJohn Marino	15 5 * * 0  echo /usr/lib/uucp/uudemon.wk | su uucp
46*86d7f5d3SJohn Marino
47*86d7f5d3SJohn MarinoOn 4.3, they'd look a little bit better, but not much:
48*86d7f5d3SJohn Marino
49*86d7f5d3SJohn Marino	5 * * * *   uucp  /usr/lib/uucp/uudemon.hr
50*86d7f5d3SJohn Marino	10 4 * * *  uucp  /usr/lib/uucp/uudemon.day
51*86d7f5d3SJohn Marino	15 5 * * 0  uucp  /usr/lib/uucp/uudemon.wk
52*86d7f5d3SJohn Marino
53*86d7f5d3SJohn MarinoFor this cron, you'd create /usr/lib/uucp/crontab.src (or wherever you want
54*86d7f5d3SJohn Marinoto keep uucp's commands) which would look like this:
55*86d7f5d3SJohn Marino
56*86d7f5d3SJohn Marino	# /usr/lib/uucp/crontab.src - uucp's crontab
57*86d7f5d3SJohn Marino	#
58*86d7f5d3SJohn Marino	PATH=/usr/lib/uucp:/bin:/usr/bin
59*86d7f5d3SJohn Marino	SHELL=/bin/sh
60*86d7f5d3SJohn Marino	HOME=/usr/lib/uucp
61*86d7f5d3SJohn Marino	#
62*86d7f5d3SJohn Marino	5 * * * *   uudemon.hr
63*86d7f5d3SJohn Marino	10 4 * * *  uudemon.day
64*86d7f5d3SJohn Marino	15 5 * * 0  uudemon.wk
65*86d7f5d3SJohn Marino
66*86d7f5d3SJohn MarinoThe application to the `news' cron commands (if any) is left for you to
67*86d7f5d3SJohn Marinofigure out.  Likewise if there are any other cruddy-looking 'su' commands in
68*86d7f5d3SJohn Marinoyour crontab commands, you don't need them anymore: just find a good place
69*86d7f5d3SJohn Marinoto put the `crontab.src' (or whatever you want to call it) file for that
70*86d7f5d3SJohn Marinouser, put the cron commands into it, and install it using the `crontab'
71*86d7f5d3SJohn Marinocommand (probably with "-u USERNAME", but see the man page).
72*86d7f5d3SJohn Marino
73*86d7f5d3SJohn MarinoIf you run a 4.2-derived cron, you could of course just install your current
74*86d7f5d3SJohn Marinocrontab in toto as root's crontab.  It would work exactly the way your
75*86d7f5d3SJohn Marinocurrent one does, barring the extra steps in installing or changing it.
76*86d7f5d3SJohn MarinoThere would still be advantages to this cron, mostly that you get mail if
77*86d7f5d3SJohn Marinothere is any output from your cron commands.
78*86d7f5d3SJohn Marino
79*86d7f5d3SJohn MarinoOne note about getting mail from cron: you will probably find, after you
80*86d7f5d3SJohn Marinoinstall this version of cron, that your cron commands are generating a lot
81*86d7f5d3SJohn Marinoof irritating output.  The work-around for this is to redirect all EXPECTED
82*86d7f5d3SJohn Marinooutput to a per-execution log file, which you can examine if you want to
83*86d7f5d3SJohn Marinosee the output from the "last time" a command was executed; if you get any
84*86d7f5d3SJohn MarinoUNEXPECTED output, it will be mailed to you.  This takes a while to get
85*86d7f5d3SJohn Marinoright, but it's amazingly convenient.  Trust me.
86*86d7f5d3SJohn Marino
87