SCO UNIX 3.2.2 Can't set login uid from cron

Dave Remien dave at pmafire.inel.gov
Sun Apr 7 08:53:49 AEST 1991


In article <boogie at dce.ie> em at dce.ie (Eamonn McManus) writes:
=>As an alternative to launching cron from rc, you can have it spawned by
=>init.  This is a little complicated, because the first thing the cron
=>daemon does is to fork itself into the background.  If you just try to
=>launch it from inittab, init will think it has finished immediately and
=>will end up launching a lot of cron daemons.  What we do here is to launch
=>a shell script that starts cron and then execs `pause', a program that
=>just does a pause() system call.  Then when we want a new cron, we kill
=>the existing cron and the `pause'.
=> [...]
=>Here is /etc/startcron, which we invoked from /etc/inittab:
=>: use /bin/sh
=># Start cron by removing an old FIFO and starting cron itself.
=># We need this script because inittab commands are execed so there
=># can't be more than one shell command.
=># Aug 17 1990
=>rm -f /usr/lib/cron/FIFO
=>trap "" 2 3	# Don't let console quit and intr affect cron.
=>. /etc/TIMEZONE	# Probably don't need
=>/etc/cron
=># Cron forks into the background so this script waits forever; kill the
=># script when you kill cron, if you want to start a new cron.
=>exec /etc/pause

Instead of the pause, why not:

sleep 2  # give cron time to fork and settle down
exec wait_on `ps -e | grep cron | awk '{print $1}'`



Where wait_on.c is:

main(argc, argv)
int argc;
char *argv[];
{
	int proc_pid;
	proc_pid = atoi(argv[1]);
	while(!kill(proc_pid, 0))sleep(1);
}

At least you only have to croak the cron, that way.

Dave
-- 
Dave Remien +*+*+*+*+*+*+*+*+*+*+*+*+*+*+ WINCO Computer Engineering Group 
  dave at pmafire.inel.gov or rzd at inel.gov      "Dave Barry for President" 



More information about the Comp.unix.sysv386 mailing list