#!/bin/sh -f # # Check that crond is running. Returns ZERO if cron daemon is running. # Returns nonzero if cron daemon is NOT running and prints a warning. # # The -v flag forces a message giving you the crond status in any case. # # It makes no sense to run this from cron! Instead, put it in # precmd or periodic in your .tcshrc or in PROMP_COMMAND in your .bashrc # # Eric Myers - 21 June 1999 # Department of Physics, University of Michigan, Ann Arbor # @(#) $Id: ckcrond,v 1.3 2002/08/14 23:05:09 myers Exp myers $ ####################################################################### PATH=/bin:/usr/bin:/usr/local/bin # Command line arguments: verbose=0 args= case $# in 0) ;; *) case $1 in -v) verbose=1 shift ;; *) args="$args $1" shift ;; esac esac # Get the PID of cron process (system specific) UNAME=`uname` PID= case $UNAME in Linux) PID=`ps ax |awk '$5 ~ /crond$/ { print $1}' ` PSCMD="ps $PID " ;; Darwin) PID=`ps ax |awk '$5 ~ /cron$/ { print $1}' ` PSCMD="ps $PID " ;; HP-UX) PID=`ps -ef |awk '$9 ~ /cron$/ { print $2}' ` PSCMD="ps -p $PID " ;; *) esac ## Now check for a non-zero PID if [ "$PID" = "" ]; then echo "ckcrond: crond is NOT running!" exit 1 else if [ $verbose = 1 ]; then echo "ckcrond: crond is running!" $PSCMD fi exit 0 fi