86 lines
1.6 KiB
Bash
Executable file
86 lines
1.6 KiB
Bash
Executable file
#!/bin/sh
|
|
# Startup script for anacron
|
|
#
|
|
# chkconfig: 2345 95 05
|
|
# description: Run cron jobs that were left out due to downtime
|
|
# pidfile: /var/run/anacron.pid
|
|
#
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
[ -f /usr/sbin/anacron ] || exit 0
|
|
|
|
prog="anacron"
|
|
PIDFILE=/var/spool/anacron/cron.daily
|
|
LOCKFILE=/var/lock/subsys/$prog
|
|
#
|
|
# NOTE: anacron exits after it has determined it has no more work to do.
|
|
# Hence, its initscript cannot do normal lock file management.
|
|
# The anacron binary now creates its own timestamps in files
|
|
# /var/spool/anacron/cron.{daily,monthly,weekly}
|
|
# and /var/lock/subsys lock files.
|
|
#
|
|
|
|
start() {
|
|
echo -n $"Starting $prog: "
|
|
# on_ac_power doesn't exist, on_ac_power returns 0 (ac power being used)
|
|
if test -x /usr/bin/on_ac_power
|
|
then
|
|
/usr/bin/on_ac_power > /dev/null
|
|
if test $? -eq 1
|
|
then
|
|
echo "deferred while on battery power."
|
|
RETVAL=0
|
|
exit 0
|
|
fi
|
|
fi
|
|
daemon +19 anacron -s
|
|
RETVAL=$?
|
|
if [ $RETVAL -ne 0 ]; then
|
|
failure;
|
|
fi;
|
|
echo
|
|
}
|
|
|
|
stop() {
|
|
echo -n $"Stopping $prog: "
|
|
if [ -f $PIDFILE ]; then
|
|
killproc $ANACRON
|
|
RETVAL=$?
|
|
if [ $RETVAL -ne 0 ]; then
|
|
failure;
|
|
fi;
|
|
else
|
|
failure;
|
|
fi
|
|
echo
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
|
|
stop)
|
|
stop
|
|
;;
|
|
|
|
status)
|
|
## anacron's status is always stopped, because anacron sleep, until
|
|
## cron wake him
|
|
status $PIDFILE
|
|
RETVAL=$?
|
|
;;
|
|
|
|
restart)
|
|
stop
|
|
start
|
|
;;
|
|
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
|
RETVAL=3
|
|
|
|
esac
|
|
|
|
exit $RETVAL
|