Como todas as suas configurações estão em ordem de acordo com a página do manual, e como o arquivo de histórico não é restrito por tamanho (bytes), a única explicação possível que posso imaginar. Tem a ver com como a concha morre.
De acordo com a referência online, a saída elegante (histórico salvo) ocorre somente quando o shell recebe SIGHUP. Eu não posso realmente explicar como seu sistema propaga sinais quando reiniciado, mas eu suspeito que seu shell saia com SIGKILL ou SIGPWR.
Poderia ser porque o seu WM é executado de forma assíncrona (espera) e o emulador de terminal gerado a partir do WM, onde o bash recebe um sinal de saída forçada diferente de SIGHUP. Também pode ser que o sistema operacional envie rapidamente o "kill final" para todos os processos antes que o SIGHUP inicial inicialize o shell via X - > WM - > xterm, possivelmente porque o X ou o WM demora mais para sair do que o operacional para o sistema operacional estar pronto para ser desativado.
Eu estou em águas profundas com essas coisas, mas acho que algo ao longo dessas linhas causa o comportamento errático. Eu tive esse problema antes, e o remédio mais sólido é exit
no bash onde você deseja manter o histórico.
Eu notei history -a
em sua pergunta e não consigo pensar em por que isso não seria suficiente para preservar o histórico.
Você pode solucionar o problema imaginando o que realmente mata o seu bash e tentar descobrir onde o sinal se origina e corrigir o problema ou simplesmente liberar o histórico quando souber qual sinal é o último (presumindo que os discos ainda estejam online até então):
trap "echo got 1 >/tmp/sig1; exit" SIGHUP
trap "echo got 2 >/tmp/sig2; exit" SIGINT
trap "echo got 15 >/tmp/sig15; exit" SIGTERM
.. and so on...
A captura de tela incluída ilustra o que estou falando no segundo e terceiro parágrafos. A sequência é que eu em shell da esquerda , mato o shell esquerdo da direita e cat o histórico.
man bash
On startup, (...) The file named by the value of HISTFILE is truncated, if necessary, to contain no
more than the number of lines specified by the value of HISTFILESIZE (+ default 500).
If the histappend shell option is enabled (+ default on here), the lines are appended to the history file, otherwise the history file is overwritten.
referência on-line
3.7.6 Signals
When Bash is interactive, in the absence of any traps, it ignores SIGTERM (so that ‘kill 0’ does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). When Bash receives a SIGINT, it breaks out of any executing loops. In all cases, Bash ignores SIGQUIT. If job control is in effect (see Job Control), Bash ignores SIGTTIN, SIGTTOU, and SIGTSTP.
Non-builtin commands started by Bash have signal handlers set to the values inherited by the shell from its parent. When job control is not in effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers. Commands run as a result of command substitution ignore the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.
The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP. To prevent the shell from sending the SIGHUP signal to a particular job, it should be removed from the jobs table with the disown builtin (see Job Control Builtins) or marked to not receive SIGHUP using disown -h.
If the huponexit shell option has been set with shopt (see The Shopt Builtin), Bash sends a SIGHUP to all jobs when an interactive login shell exits.
If Bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes. When Bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit status greater than 128, immediately after which the trap is executed.
captura de tela demonstrativa