save bash history, regularly

I have bash set up to save history, to a file. It does this whenever bash exits [properly]. As sometimes bash does not exit properly the history is lost.

So the question is can I set up bash to save history more regularly?


I am running Debian Gnu (version 6, Squeeze) with a Linux kernel.

bash version: GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)


save this to your bash_profile or bashrc

shopt -s histappend

PROMPT_COMMAND="history -a;$PROMPT_COMMAND"