For some reason, I cannot get my system to keep my BASH history after a reboot. Here are the relevant sections of my ~/.bashrc:
shopt -s histappend
PROMPT_COMMAND='history -a; updateWindowTitle'
export HISTCONTROL=ignoredups
export HISTSIZE=9999
export HISTFILESIZE=999999
export HISTFILE="$HOME/.bash_history"
As far as I can tell those are all the necessary options (I know I used to be able to keep history across multiple reboots without all of these in the past). However, despite having added these options several reboots ago, I still loose most of my history after a reboot. It is not empty, but it does not have the 9999 lines I had before rebooting.
Before anyone complains, yes I have read these questions. I have implemented some of their suggestions as listed above, the rest were either unhelpful or not relevant:
- Bash history loss when using histappend
- How to prevent Bash from altering history?
- What determines what shows up in the bash history command?
- How do I keep my bash history across sessions?
- save bash history, regularly
On the off chance that there may be other relevant commands in there, you can view my entire ~/.bashrc here.
So, what am I missing? Why is my history not saved? If anyone thinks another file may be relevant let me know and I'll post it. I checked by running grep -i hist \.* in my $HOME which showed that the only relevant . file containing the string hist or HIST was .bashrc.
I am running Linux Mint Debian Edition, GNU bash, version 4.2.36(1)-release (x86_64-pc-linux-gnu) and my favorite terminal emulator (in case that's relevant) is terminator.
UPDATE:
Following @mpy's suggestion in the comments, I changed my ~/.bashrc to set HISTFILE=~/bash_history as opposed to the default ~/.bash_history and that seems to solve the problem for interactive shells. Login shells still display the same behavior, with the history truncated at 500 lines. However, there are no HIST related variables set in the relevant files:
$ for f in /etc/profile ~/.profile ~/.bash_profile ~/.bash_login; do \
echo -ne "$f :"; echo `grep HIST $f`; \
done
/etc/profile :
/home/terdon/.profile :grep: /home/terdon/.profile: No such file or directory
/home/terdon/.bash_profile :grep: /home/terdon/.bash_profile: No such file or directory
/home/terdon/.bash_login :grep: /home/terdon/.bash_login: No such file or directory
$ grep -r HIST /etc/profile.d/ <-- returns nothing
So, why is setting HISTSIZE and HISTFILESIZE in the ~/.bashrc not enough unless I explicitly set the $HISTFILE to something other than the default ~/.bash_history?

historycommand, the output you see is identical to what you see, runningcat .bash_history, other than the the line numbers ? I mean does thehistorycommand list time stamps or other information ? The reason I am asking is, if you see these esoteric stuff, it means, there is another module/function/program, which is messing with the shell history and a wrong or buggy version of whatever it is, might be causing you the grief. – MelBurslan Mar 30 '13 at 7:54;): Try another file as HISTFILE, not the default~/.bash_history. Very constructed explanation: I assume bash is your default shell, so upon system start a non-interactive shell is the parent of your X session (I also assume you use X), which will know nothing about histappend option (as .bashrc is only read by interactive shells), so as long this parent shell runs everything is fine, but upon termination (i.e. system halt) it will override~/.bash_history(which is default) and messes up your history... – mpy Apr 2 '13 at 13:05