An init.d script to stop and start safe_asterisk started asterisk. If asterisk is not stopped in 5 seconds, it is forcibly killed.

safe_asterisk-init.d (view)

# wget http://wjd.nu/files/2012/04/safe_asterisk-init.d -O/etc/init.d/asterisk ; chmod 755 /etc/init.d/asterisk

Also possibly useful, the changes I made to safe_asterisk on a machine where:

  1. there wasn't a tty left to spam output on,
  2. root is configured in /etc/aliases to a sane destination,
  3. /var/spool/asterisk is the asterisk user homedir anyway, and,
  4. attempting to set maxfiles to the highest value possible, wasn't allowed.
#TTY=9
CONSOLE=no
NOTIFY=root
DUMPDROP=/var/spool/asterisk
MAXFILES=12288
...
run_asterisk >/dev/null 2>&1 &

asterisk bash