#!/bin/bash # # Init file for CRON daemon # # chkconfig: 2345 55 25 # description: CRON daemon # # processname: cron # pidfile: /var/run/cron.pid # source function library . /etc/rc.d/init.d/functions # pull in sysconfig settings [ -f /etc/sysconfig/cron ] && . /etc/sysconfig/sshd RETVAL=0 prog="cron" # Some functions to make the below more readable CRON=/usr/sbin/cron do_restart_sanity_check() { $CRON RETVAL=$? if [ ! "$RETVAL" = 0 ]; then failure $"Configuration file or keys are invalid" echo fi } start() { # Create keys if necessary echo -n $"Starting $prog:" daemon $CRON $OPTIONS && success || failure RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/cron echo } stop() { echo -n $"Stopping $prog:" killproc $CRON -TERM RETVAL=$? [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/cron echo } reload() { echo -n $"Reloading $prog:" killproc $CRON -HUP RETVAL=$? echo } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; reload) reload ;; condrestart) if [ -f /var/lock/subsys/cron ] ; then do_restart_sanity_check if [ "$RETVAL" = 0 ] ; then stop # avoid race sleep 3 start fi fi ;; status) status $CRON RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" RETVAL=1 esac exit $RETVAL