X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=scripts%2Fsavecore;h=29142e98e88a0b8d6441c501393ffcaff1b8c416;hp=e2b2ae0feee966f9e44ce0f6bc7b717283f038a0;hb=HEAD;hpb=154f04f2189de4b6d4bb1c89921fc3a915d11369 diff --git a/scripts/savecore b/scripts/savecore index e2b2ae0fe..29142e98e 100755 --- a/scripts/savecore +++ b/scripts/savecore @@ -18,7 +18,9 @@ # How your system names core files # # This is a pattern rather than a name, because modern kernels can put -# fancy stuff in the name we can't always predict. +# fancy stuff in the name we can't always predict. Modern user space +# can squirrel away core dumps in fancy places; you may need to switch +# that off for this insufficiently fancy script to work. core_pattern=core.* #core_pattern=emp_server.core #core_pattern=core @@ -41,20 +43,23 @@ mailx=mailx # End of configuration saved= +core_name= alert_deity () { - local msg; + local msg if [ "$saved" ] then msg="Core dump $saved_core saved." - else msg="Could not save core dump." + elif [ "$core_name" ] + then msg="Could not save core dump $core_name." + else msg="Could not find core dump to save." fi - echo $msg | $mailx -s "emp_server dumped core in $PWD" "$privlog" + echo "$msg" | $mailx -s "emp_server dumped core in $PWD" "$privlog" } test -n "$privlog" && trap 'alert_deity' EXIT -core_name=`ls -td $core_pattern | head -n 1` +core_name=`ls -td $core_pattern 2>/dev/null | head -n 1` test -n "$core_name" test -r "$core_name" tstamp=`/bin/date +%Y-%m-%d-%H:%M` @@ -62,8 +67,8 @@ saved_core=$core_dir/core-$tstamp mkdir -p $core_dir if [ `df -kP $core_dir | awk 'NR!=1 { print $4 }'` -lt "$space_low" ] -then rm -f $core_name; exit +then rm -f "$core_name"; exit fi -mv -f $core_name $saved_core +mv -f "$core_name" $saved_core saved=y