#!/bin/sh
#
# atd		Runs commands scheduled by the at command
#
# chkconfig:	345 40 60
#
# description:	Runs commands scheduled by the at command at the time \
#		specified when at was run, and runs batch commands when \
#		the load average is low enough.
#
# processname:	atd


# Source function library
. /etc/rc.d/init.d/functions

# Get service config
[ -f /etc/sysconfig/atd ] && . /etc/sysconfig/atd

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/atd ]; then
		msg_starting at
		daemon atd
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/atd
	else
		msg_already_running atd
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/atd ]; then
		msg_stopping at
		killproc atd
		rm -f /var/lock/subsys/atd
	else
		msg_not_running atd
	fi
	;;
  force-reload|restart)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status atd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
