For some reason, I cannot get my system to keep my BASH history after a reboot. Here are the relevant sections of my
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
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
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
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
HISTFILESIZE in the
~/.bashrc not enough unless I explicitly set the
$HISTFILE to something other than the default