LFS does not save bash history on shutdown

Jason Aeschilman jason-lists at fatpipeinc.com
Mon Jun 19 15:13:32 PDT 2006

Matthias B. wrote:
> On Tue, 13 Jun 2006 12:23:03 -0600 Jason Aeschilman
> <jason-lists at fatpipeinc.com> wrote:
>> ash history is not saved on shutdown.  I have commented out the line 
>> "unset HISTFILE" from /etc/profile so now history is saved for root, but
>> it only works when I log out of a terminal.  If I reboot or shutdown, 
>> the history does not get saved to ~/.bash_history.  Does anyone know how
>> this can be fixed?  Shouldn't this be standard on the LFS system?  Even 
>> if you keep "unset HISTFILE" for root, regular users should not lose 
>> their bash history on shutdown.
> Are you sure that you are losing history rather than getting the history
> for some interactive shell that you had open but didn't use?
> AFAIK, by default, bash overwrites the history file on exit, i.e. the last
> shell that terminates gets to write the history. When you shut down,
> shells terminate in no well-defined order so that with
> history-overwriting, the shell that wins the race to write history may
> just be the wrong one.
> Try putting
> shopt -s histappend
> into your /etc/profile and see if that fixes your problem. This will cause
> bash to append to the history file rather than overwrite it, thereby
> causing your history to store history from all shells, not just the one
> terminated last.
I have exactly one console session up.  So it's not a case where one 
console is overwriting another.  I suppose sending the SIGHUP signal to 
all bash processes on shutdown may be the best solution.

More information about the blfs-support mailing list