thad@cup.portal.com (Thad P Floryan) (02/05/90)
In a quest to simplify system administration, I desired to make the cronlog easier to scan for any "funny business." As you know, the use of "here is" files (e.g. command << FOO ...text... FOO) implied by using a crontab entry such as: 16,46 * * * * /bin/su uucpadm % /usr/lib/uucp/uudemon.admin >/dev/null produces a very cluttered cronlog. After RTFM for sh(1), ksh(1), su(1), it still wasn't clear WHY some of the default crontab entries are like the above entry (ref. ``%'') and why some are like the following (ref. ``-c "...." ''): 18,48 * * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" crontab entries (at least on my systems) are executed as "root", so I figured I'd switch to using "-c" for all crontab entries and see a readable cronlog. A few entries had to be changed from "/bin/su" to "/bin/sh", but otherwise everything works fine (even with /bin/ksh as root's shell in /etc/passwd) and an extraction of crontab now looks like: 16,46 * * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" 18,48 * * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" 00 4 * * * /bin/su uucpadm -c "/usr/lib/uucp/uudemon.admin >/dev/null" 59 23 * * * /bin/sh -c "/usr/local/bin/hdwarn.day >/dev/null" 59 23 * * * /bin/sh -c "/usr/local/bin/du-logs.day >/dev/null" 03 3 * * 0 /bin/sh -c "/etc/clockupd.wk >/dev/null" 30 5 * * 1 /bin/su uucpadm -c "/usr/lib/uucp/uudemon.cleanu >/dev/null" 30 5 * * 1 /bin/sh -c "/etc/cleanup.wk >/dev/null" and a corresponding sample of cronlog output now looks like the following two hours' entries: Mon Jan 29 23:00:00 1990 /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" /bin/sh -c "/usr/local/bin/hdwarn.day >/dev/null" /bin/sh -c "/usr/local/bin/du-logs.day >/dev/null" Sun Feb 4 03:00:00 1990 /bin/sh -c "/etc/clockupd.wk >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.poll >/dev/null" /bin/su uucpadm -c "/usr/lib/uucp/uudemon.hour >/dev/null" I've been running one system this way for over a week now with no apparent problems. As you can see, the cronlog entries are far easier to quickly scan. I trust you find this tip useful! However, I'm still puzzled why ALL the default examples I've seen in crontabs on many systems mix both the "%" and "-c" usage in the same file. Is there any real reason for invoking (otherwise similar) scripts using one method or the other? Thad Floryan [ thad@cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]
jcm@mtune.ATT.COM (John McMillan) (02/06/90)
In article <26611@cup.portal.com> thad@cup.portal.com (Thad P Floryan) writes: : >However, I'm still puzzled why ALL the default examples I've seen in crontabs >on many systems mix both the "%" and "-c" usage in the same file. Is there >any real reason for invoking (otherwise similar) scripts using one method or >the other? : "%" is the equivalent of a NL. Everything after the 1st is fed as standard input to the shell invoked by the SU command. I would imagine there ARE obscure differences in certain circumstances. More obviously, I read the documentation as suggesting multiple "%" would result in multiple lines. (No, I'm not taking the time to test this.) Often the CRON file[s] on systems are built by many scripts. When a script-writer adds her part, she doesn't necessarily have the context -- ie., others' contributions -- before her. This is really no different from the variety of tools in other languages or other parts of the Shells: "A trite consistance is the hobgoblin of little minds." Enjoy diversity!-) john mcmillan -- att!mtunb!jcm -- muttering for self, not THEM