#!/bin/sh # # anacron Run cron jobs that were left out due to downtime. # # chkconfig: 2345 99 05 # description: 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 /var/run/anacron.pid pid file \ # and /var/lock/subsys lock files, and removes them automatically at exit, \ # so at least there will be no more "anacron is dead but subsys locked" \ # messages. ### BEGIN INIT INFO # Provides: $anacron # Required-Start: $local_fs $syslog # Required-Stop: $local_fs $syslog # Default-Start: 2345 # Default-Stop: 99 # Short-Description: run left over cron jobs # Description: 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 /var/run/anacron.pid pid file # and /var/lock/subsys lock files, and removes them automatically at exit, # so at least there will be no more "anacron is dead but subsys locked" # messages. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions exec=/usr/sbin/anacron prog=anacron #config=doesn't have config file, some values are stored in /etc/anacrontab lockfile=/var/lock/subsys/$prog start() { [ -x $exec ] || exit 5 echo -n $"Starting $prog: " daemon +19 anacron -s retval=$? echo [ $retval -eq 0 ] ## && touch $lockfile it creates lock in code return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog retval=$? echo [ $retval -eq 0 ] #usually anacron clean his lock after he stops himself. #Just in case something goes wrong kill him. [ -f $lockfile ] && rm -f $lockfile return $retval } restart() { stop start } rh_status() { # run checks to determine if the service is running or use generic status status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; status) rh_status ;; condrestart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart}" exit 2 esac exit $?