#!/bin/dash
# Description: System task scheduler (dcron)
# jamesbond 2012

MAIL_TARGET=root # change this
DAEMON=/usr/sbin/crond

start_cron() {
	echo "Starting task scheduler."
	$DAEMON -m $MAIL_TARGET
}

stop_cron() {
	echo "Stopping task scheduler."
	pkill -f $DAEMON
}

is_up_cron() {
	pkill -0 -f $DAEMON
}

case $1 in
	start)
		start_cron
		;;
		
	stop)
		stop_cron
		;;
		
	restart)
		stop_cron
		sleep 1
		start_cron
		;;
		
	status)
		is_up_cron && echo "dcron is running." || echo "dcron is stopped."
		;;		
		
esac
