at/atd.init
2008-02-28 09:34:57 +00:00

95 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# /etc/rc.d/init.d/atd
#
# Starts the "at" daemon
#
# chkconfig: 345 95 5
# 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/init.d/functions
# pull in sysconfig settings
[ -f /etc/sysconfig/atd ] && . /etc/sysconfig/atd
RETVAL=0
prog="atd"
ATD=/usr/sbin/atd
LOCK_FILE=/var/lock/subsys/atd
[ -f /etc/sysconfig/atd ] || exit 6
start() {
# Check if atd is already running
echo -n $"Starting $prog: "
$ATD $OPTS && success || failure
RETVAL=$?
[ "$RETVAL" = 0 ] && touch $LOCK_FILE
echo
}
stop() {
echo -n $"Stopping $prog: "
if [ -n "`pidfileofproc $ATD`" ] ; then
killproc $ATD
else
failure $"Stopping $prog"
fi
RETVAL=$?
[ "$RETVAL" = 0 ] && rm -f $LOCK_FILE
echo
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $prog: "
if [ -n "`pidfileofproc $ATD`" ]; then
killproc $ATD -HUP
else
failure $"Reloading $prog"
fi
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
condrestart)
if [ -f $LOCK_FILE ]; then
if [ "$RETVAL" = 0 ]; then
stop
sleep 3
start
fi
fi
;;
status)
status $ATD
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=3
esac
exit $RETVAL