Need a list of the currently running cron jobs? Then try this:
#!/usr/bin/sh cronpid=`ps -ef | grep cron | grep -v pts | awk '{print $2}'` # Following line needs curly braces because of the underscore outfile="/tmp/${USER}_$cronpid.txt" echo "Cron running under following PID: $cronpid" ps -ef | grep $cronpid | grep -v pts | grep -v /usr/sbin/cron > $outfile jobcount=`cat $outfile | wc -l` if [ $jobcount -eq 0 ]; then echo "There are no jobs running at present" else echo "Running cron jobs:" cat $outfile echo "Number of running jobs: $jobcount" rm $outfile fi
This works well for me on the following: