xref: /dflybsd-src/usr.sbin/cron/doc/CONVERSION (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino$FreeBSD: src/usr.sbin/cron/doc/CONVERSION,v 1.4 1999/08/28 01:15:52 peter Exp $
286d7f5d3SJohn Marino$DragonFly: src/usr.sbin/cron/doc/CONVERSION,v 1.3 2004/01/08 18:39:19 asmodai Exp $
386d7f5d3SJohn Marino
486d7f5d3SJohn MarinoConversion of BSD 4.[23] crontab files:
586d7f5d3SJohn Marino
686d7f5d3SJohn MarinoEdit your current crontab (/usr/lib/crontab) into little pieces, with each
786d7f5d3SJohn Marinousers' commands in a different file.  This is different on 4.2 and 4.3,
886d7f5d3SJohn Marinobut I'll get to that below.  The biggest feature of this cron is that you
986d7f5d3SJohn Marinocan move 'news' and 'uucp' cron commands into files owned and maintainable
1086d7f5d3SJohn Marinoby those two users.  You also get to rip all the fancy 'su' footwork out
1186d7f5d3SJohn Marinoof the cron commands.  On 4.3, there's no need for the 'su' stuff since the
1286d7f5d3SJohn Marinouser name appears on each command -- but I'd still rather have separate
1386d7f5d3SJohn Marinocrontabs with separate environments and so on.
1486d7f5d3SJohn Marino
1586d7f5d3SJohn MarinoLeave the original /usr/lib/crontab!  This cron doesn't use it, so you may
1686d7f5d3SJohn Marinoas well keep it around for a while in case something goes wakko with this
1786d7f5d3SJohn Marinofancy version.
1886d7f5d3SJohn Marino
1986d7f5d3SJohn MarinoMost commands in most crontabs are run by root, have to run by root, and
2086d7f5d3SJohn Marinoshould continue to be run by root.  They still have to be in their own file;
2186d7f5d3SJohn MarinoI recommend /etc/crontab.src or /usr/adm/crontab.src.
2286d7f5d3SJohn Marino
2386d7f5d3SJohn Marino'uucp's commands need their own file; how about /usr/lib/uucp/crontab.src?
2486d7f5d3SJohn Marino'news' also, perhaps in /usr/lib/news/crontab.src...
2586d7f5d3SJohn Marino
2686d7f5d3SJohn MarinoI say `how about' and `perhaps' because it really doesn't matter to anyone
2786d7f5d3SJohn Marino(except you) where you put the crontab source files.  The `crontab' command
2886d7f5d3SJohn MarinoCOPIES them into a protected directory (CRONDIR/SPOOL_DIR in cron.h), named
2986d7f5d3SJohn Marinoafter the user whose crontab it is.  If you want to examine, replace, or
3086d7f5d3SJohn Marinodelete a crontab, the `crontab' command does all of those things.  The
3186d7f5d3SJohn Marinovarious `crontab.src' (my suggested name for them) files are just source
3286d7f5d3SJohn Marinofiles---they have to be copied to SPOOLDIR using `crontab' before they'll be
3386d7f5d3SJohn Marinoexecuted.
3486d7f5d3SJohn Marino
3586d7f5d3SJohn MarinoOn 4.2, your crontab might have a few lines like this:
3686d7f5d3SJohn Marino
3786d7f5d3SJohn Marino	5 * * * *   su uucp < /usr/lib/uucp/uudemon.hr
3886d7f5d3SJohn Marino	10 4 * * *  su uucp < /usr/lib/uucp/uudemon.day
3986d7f5d3SJohn Marino	15 5 * * 0  su uucp < /usr/lib/uucp/uudemon.wk
4086d7f5d3SJohn Marino
4186d7f5d3SJohn Marino...or like this:
4286d7f5d3SJohn Marino
4386d7f5d3SJohn Marino	5 * * * *   echo /usr/lib/uucp/uudemon.hr | su uucp
4486d7f5d3SJohn Marino	10 4 * * *  echo /usr/lib/uucp/uudemon.day | su uucp
4586d7f5d3SJohn Marino	15 5 * * 0  echo /usr/lib/uucp/uudemon.wk | su uucp
4686d7f5d3SJohn Marino
4786d7f5d3SJohn MarinoOn 4.3, they'd look a little bit better, but not much:
4886d7f5d3SJohn Marino
4986d7f5d3SJohn Marino	5 * * * *   uucp  /usr/lib/uucp/uudemon.hr
5086d7f5d3SJohn Marino	10 4 * * *  uucp  /usr/lib/uucp/uudemon.day
5186d7f5d3SJohn Marino	15 5 * * 0  uucp  /usr/lib/uucp/uudemon.wk
5286d7f5d3SJohn Marino
5386d7f5d3SJohn MarinoFor this cron, you'd create /usr/lib/uucp/crontab.src (or wherever you want
5486d7f5d3SJohn Marinoto keep uucp's commands) which would look like this:
5586d7f5d3SJohn Marino
5686d7f5d3SJohn Marino	# /usr/lib/uucp/crontab.src - uucp's crontab
5786d7f5d3SJohn Marino	#
5886d7f5d3SJohn Marino	PATH=/usr/lib/uucp:/bin:/usr/bin
5986d7f5d3SJohn Marino	SHELL=/bin/sh
6086d7f5d3SJohn Marino	HOME=/usr/lib/uucp
6186d7f5d3SJohn Marino	#
6286d7f5d3SJohn Marino	5 * * * *   uudemon.hr
6386d7f5d3SJohn Marino	10 4 * * *  uudemon.day
6486d7f5d3SJohn Marino	15 5 * * 0  uudemon.wk
6586d7f5d3SJohn Marino
6686d7f5d3SJohn MarinoThe application to the `news' cron commands (if any) is left for you to
6786d7f5d3SJohn Marinofigure out.  Likewise if there are any other cruddy-looking 'su' commands in
6886d7f5d3SJohn Marinoyour crontab commands, you don't need them anymore: just find a good place
6986d7f5d3SJohn Marinoto put the `crontab.src' (or whatever you want to call it) file for that
7086d7f5d3SJohn Marinouser, put the cron commands into it, and install it using the `crontab'
7186d7f5d3SJohn Marinocommand (probably with "-u USERNAME", but see the man page).
7286d7f5d3SJohn Marino
7386d7f5d3SJohn MarinoIf you run a 4.2-derived cron, you could of course just install your current
7486d7f5d3SJohn Marinocrontab in toto as root's crontab.  It would work exactly the way your
7586d7f5d3SJohn Marinocurrent one does, barring the extra steps in installing or changing it.
7686d7f5d3SJohn MarinoThere would still be advantages to this cron, mostly that you get mail if
7786d7f5d3SJohn Marinothere is any output from your cron commands.
7886d7f5d3SJohn Marino
7986d7f5d3SJohn MarinoOne note about getting mail from cron: you will probably find, after you
8086d7f5d3SJohn Marinoinstall this version of cron, that your cron commands are generating a lot
8186d7f5d3SJohn Marinoof irritating output.  The work-around for this is to redirect all EXPECTED
8286d7f5d3SJohn Marinooutput to a per-execution log file, which you can examine if you want to
8386d7f5d3SJohn Marinosee the output from the "last time" a command was executed; if you get any
8486d7f5d3SJohn MarinoUNEXPECTED output, it will be mailed to you.  This takes a while to get
8586d7f5d3SJohn Marinoright, but it's amazingly convenient.  Trust me.
8686d7f5d3SJohn Marino
87