xref: /freebsd/usr.sbin/cron/doc/CONVERSION (revision 84f33dea627930e57209583fc83ffb3202babc0a)
184f33deaSJordan K. Hubbard$Id: CONVERSION,v 2.2 1993/12/28 08:34:43 vixie Exp $
284f33deaSJordan K. Hubbard
384f33deaSJordan K. HubbardConversion of BSD 4.[23] crontab files:
484f33deaSJordan K. Hubbard
584f33deaSJordan K. HubbardEdit your current crontab (/usr/lib/crontab) into little pieces, with each
684f33deaSJordan K. Hubbardusers' commands in a different file.  This is different on 4.2 and 4.3,
784f33deaSJordan K. Hubbardbut I'll get to that below.  The biggest feature of this cron is that you
884f33deaSJordan K. Hubbardcan move 'news' and 'uucp' cron commands into files owned and maintainable
984f33deaSJordan K. Hubbardby those two users.  You also get to rip all the fancy 'su' footwork out
1084f33deaSJordan K. Hubbardof the cron commands.  On 4.3, there's no need for the 'su' stuff since the
1184f33deaSJordan K. Hubbarduser name appears on each command -- but I'd still rather have separate
1284f33deaSJordan K. Hubbardcrontabs with seperate environments and so on.
1384f33deaSJordan K. Hubbard
1484f33deaSJordan K. HubbardLeave the original /usr/lib/crontab!  This cron doesn't use it, so you may
1584f33deaSJordan K. Hubbardas well keep it around for a while in case something goes wakko with this
1684f33deaSJordan K. Hubbardfancy version.
1784f33deaSJordan K. Hubbard
1884f33deaSJordan K. HubbardMost commands in most crontabs are run by root, have to run by root, and
1984f33deaSJordan K. Hubbardshould continue to be run by root.  They still have to be in their own file;
2084f33deaSJordan K. HubbardI recommend /etc/crontab.src or /usr/adm/crontab.src.
2184f33deaSJordan K. Hubbard
2284f33deaSJordan K. Hubbard'uucp's commands need their own file; how about /usr/lib/uucp/crontab.src?
2384f33deaSJordan K. Hubbard'news' also, perhaps in /usr/lib/news/crontab.src...
2484f33deaSJordan K. Hubbard
2584f33deaSJordan K. HubbardI say `how about' and `perhaps' because it really doesn't matter to anyone
2684f33deaSJordan K. Hubbard(except you) where you put the crontab source files.  The `crontab' command
2784f33deaSJordan K. HubbardCOPIES them into a protected directory (CRONDIR/SPOOL_DIR in cron.h), named
2884f33deaSJordan K. Hubbardafter the user whose crontab it is.  If you want to examine, replace, or
2984f33deaSJordan K. Hubbarddelete a crontab, the `crontab' command does all of those things.  The
3084f33deaSJordan K. Hubbardvarious `crontab.src' (my suggested name for them) files are just source
3184f33deaSJordan K. Hubbardfiles---they have to be copied to SPOOLDIR using `crontab' before they'll be
3284f33deaSJordan K. Hubbardexecuted.
3384f33deaSJordan K. Hubbard
3484f33deaSJordan K. HubbardOn 4.2, your crontab might have a few lines like this:
3584f33deaSJordan K. Hubbard
3684f33deaSJordan K. Hubbard	5 * * * *   su uucp < /usr/lib/uucp/uudemon.hr
3784f33deaSJordan K. Hubbard	10 4 * * *  su uucp < /usr/lib/uucp/uudemon.day
3884f33deaSJordan K. Hubbard	15 5 * * 0  su uucp < /usr/lib/uucp/uudemon.wk
3984f33deaSJordan K. Hubbard
4084f33deaSJordan K. Hubbard...or like this:
4184f33deaSJordan K. Hubbard
4284f33deaSJordan K. Hubbard	5 * * * *   echo /usr/lib/uucp/uudemon.hr | su uucp
4384f33deaSJordan K. Hubbard	10 4 * * *  echo /usr/lib/uucp/uudemon.day | su uucp
4484f33deaSJordan K. Hubbard	15 5 * * 0  echo /usr/lib/uucp/uudemon.wk | su uucp
4584f33deaSJordan K. Hubbard
4684f33deaSJordan K. HubbardOn 4.3, they'd look a little bit better, but not much:
4784f33deaSJordan K. Hubbard
4884f33deaSJordan K. Hubbard	5 * * * *   uucp  /usr/lib/uucp/uudemon.hr
4984f33deaSJordan K. Hubbard	10 4 * * *  uucp  /usr/lib/uucp/uudemon.day
5084f33deaSJordan K. Hubbard	15 5 * * 0  uucp  /usr/lib/uucp/uudemon.wk
5184f33deaSJordan K. Hubbard
5284f33deaSJordan K. HubbardFor this cron, you'd create /usr/lib/uucp/crontab.src (or wherever you want
5384f33deaSJordan K. Hubbardto keep uucp's commands) which would look like this:
5484f33deaSJordan K. Hubbard
5584f33deaSJordan K. Hubbard	# /usr/lib/uucp/crontab.src - uucp's crontab
5684f33deaSJordan K. Hubbard	#
5784f33deaSJordan K. Hubbard	PATH=/usr/lib/uucp:/bin:/usr/bin
5884f33deaSJordan K. Hubbard	SHELL=/bin/sh
5984f33deaSJordan K. Hubbard	HOME=/usr/lib/uucp
6084f33deaSJordan K. Hubbard	#
6184f33deaSJordan K. Hubbard	5 * * * *   uudemon.hr
6284f33deaSJordan K. Hubbard	10 4 * * *  uudemon.day
6384f33deaSJordan K. Hubbard	15 5 * * 0  uudemon.wk
6484f33deaSJordan K. Hubbard
6584f33deaSJordan K. HubbardThe application to the `news' cron commands (if any) is left for you to
6684f33deaSJordan K. Hubbardfigure out.  Likewise if there are any other cruddy-looking 'su' commands in
6784f33deaSJordan K. Hubbardyour crontab commands, you don't need them anymore: just find a good place
6884f33deaSJordan K. Hubbardto put the `crontab.src' (or whatever you want to call it) file for that
6984f33deaSJordan K. Hubbarduser, put the cron commands into it, and install it using the `crontab'
7084f33deaSJordan K. Hubbardcommand (probably with "-u USERNAME", but see the man page).
7184f33deaSJordan K. Hubbard
7284f33deaSJordan K. HubbardIf you run a 4.2-derived cron, you could of course just install your current
7384f33deaSJordan K. Hubbardcrontab in toto as root's crontab.  It would work exactly the way your
7484f33deaSJordan K. Hubbardcurrent one does, barring the extra steps in installing or changing it.
7584f33deaSJordan K. HubbardThere would still be advantages to this cron, mostly that you get mail if
7684f33deaSJordan K. Hubbardthere is any output from your cron commands.
7784f33deaSJordan K. Hubbard
7884f33deaSJordan K. HubbardOne note about getting mail from cron: you will probably find, after you
7984f33deaSJordan K. Hubbardinstall this version of cron, that your cron commands are generating a lot
8084f33deaSJordan K. Hubbardof irritating output.  The work-around for this is to redirect all EXPECTED
8184f33deaSJordan K. Hubbardoutput to a per-execution log file, which you can examine if you want to
8284f33deaSJordan K. Hubbardsee the output from the "last time" a command was executed; if you get any
8384f33deaSJordan K. HubbardUNEXPECTED output, it will be mailed to you.  This takes a while to get
8484f33deaSJordan K. Hubbardright, but it's amazingly convenient.  Trust me.
8584f33deaSJordan K. Hubbard
86