Skip to content

Instantly share code, notes, and snippets.

@jsimpsoncd
Created May 21, 2014 18:44
Show Gist options
  • Save jsimpsoncd/767cca0a434829e1310c to your computer and use it in GitHub Desktop.
Save jsimpsoncd/767cca0a434829e1310c to your computer and use it in GitHub Desktop.
#!/bin/bash
filemtime=`stat -c %Y /var/tmp/crashme.lock`
currmtime=`date +%s`
diffmtime=$(($currmtime - $filemtime))
if [ $diffmtime -lt 600 ]
then
touch /var/tmp/crashme.lock
DATE=`date +%Y%m%d-%H%M`
LOG=/var/tmp/CRASHLOG-${DATE}.log
/bin/ps auxHww -L > ${LOG}
/usr/sbin/asterisk -rx 'core show locks' >> ${LOG}
/bin/kill -s SIGSEGV `cat /var/run/asterisk.pid`
/bin/echo "asterisk crashed. safe asterisk should restart it and kill mpg123 automatically"
else
echo "Existing lockfile, confirm that server has not been recently deleted and delete /var/tmp/crashme.lock"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment