#! /bin/sh
#
# |-----------------------------------------------------------|
# | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc.      |
# | All Rights Reserved                                       |
# |-----------------------------------------------------------|
# |          Restricted Rights Legend                         |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in                   |
# | subparagraph (c)(1)(ii) of the Rights in Technical        |
# | Data and Computer Software Clause of DFARS 252.227-7013.  |
# |         MIPS Computer Systems, Inc.                       |
# |         950 DeGuigne Avenue                               |
# |         Sunnyvale, California 94088-3650, USA             |
# |-----------------------------------------------------------|
#
# $Header: cron,v 1.12.2.1 92/06/24 13:34:58 marker Exp $

#	cron control

#
# killcron() kills any currently running cron processes.  Note
# that the current shell script is called cron, so it must be
# ignored.  Also note that you can't use a pipe with a while
# loop because it will generate another process called "cron".
#

killcron()
{
	PATH=/bin:/usr/bin:/etc:
	pidlist=`ps -e |\
		grep ' cron$' |\
		sed -n 's/^[ 	]*\([0-9]*\)[ 	].*$/\1/p'`
	case "$pidlist" in
		"")
			return
			;;
	esac

	for pid in $pidlist
	{
		case "$pid" in
			"$$")
				;;
			*)
				/bin/kill "$pid" >/dev/null 2>&1
				;;
		esac
	}
}
case $1 in
'start')
	killcron

	rm -f /usr/lib/cron/FIFO
	if [ -x /usr/bin/cron ]
	then
		/usr/bin/cron
	elif [ -x /etc/cron ]
	then
		/etc/cron
	fi
	;;
'stop')
	killcron
	;;
*)
	echo "usage: /etc/init.d/cron {start|stop}"
	;;
esac
exit 0
