#!/bin/sh # # core_cron_daemon -- for all new files in /var/core that match # a pattern set via coreadm, analyze them, email the results # to the sysadmin team, and then a week later delete them. # If you need to save a core, just gzip it and it won't # match the pattern. # The pattern is core__java_110_102_1181276668_2441 # whch is host prog uid gid timestamp pid # Requires a modified mdebug script and /bin/mdb, and has to # be run by root's crontab in order to read /var/core. # ProgName=`basename $0` BIN=/usr/local/bin main() { cd /var/core find . -name 'core_*' -mtime -1 -print | grep -v '\.gz' |\ while read file junk; do file=`basename $file` analyze $file >analysis_of_$file mv $file analyzed_$file done find . -name 'analyzed_*' -mtime +7 -print | grep -v '\.gz' |\ while read file junk; do rm $file done } analyze() { name=$1 app=`echo $name | nawk -F_ '{print $3}'` path=`which $app` set '' $path case "$2" in "no") path="-" ;; # Insert a placeholder *) ;; esac $BIN/mdebug 2 $path $name } say() { echo "$@" 1>&2 } main "$@"