I don't think, that increasing the history buffer in bash is sufficient.

One cause of data loss not yet discussed here is the user's .history file
itself.
Normally users work in one shell, and when that exits, bash saces its
history there, so that the next shell the user runs can read from there.
With screen, one user has often multiple bash running concurrently, and
when screen exits, all bash processes are exiting simultaneously,
and each of them is updating the same .history file.

This can lead to data loss, if the data coming from each of them is not
serialized properly.
See
-
https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
-
https://unix.stackexchange.com/questions/88838/preserve-tcsh-history-in-multiple-terminal-windows

(The tcsh history merge feature was especially implemented to handle
serialization from multiple shells exiting simultaneously. But that was
decades ago.
I cannot judge how reliable the shells are in these edge cases.)

cheers, JW-

On Tue, Nov 9, 2021 at 5:01 AM Roger <rogerx....@gmail.com> wrote:

> I have frequently noticed GNU Screen with multiple Bash shells, each
> shell/tab,
> the history is routinely forgotten/lost.
>
> A possible solution is to increase Bash history command and file size:
>
> Here I increased from 150 to 15,000(lines/MB)
>
> export HISTSIZE=15000
> export HISTFILESIZE=15000
>
> Sort of ridiculous, and I think the cause is more related to not safely
> exiting each shell/tab prior to halt.
>
> Maybe the proper method to halt a system is to send a signal to GNU
> Screen, and place it within a halt.sh script?
>
> Roger
>
> > On Sun, Nov 07, 2021 at 06:20:08PM +0400, Vishal Priyatham wrote:
> >   Thanks Robin for the reply.Â
> >   looks like we lost the history then as the screen session killed
> >   now. Â
> >   Regards,
> >   Vishal
> >
> >   On Sun, Nov 7, 2021 at 10:28 AM Robin Lee Powell
> >   <robinleepow...@gmail.com> wrote:
> >
> >     Well, the normal shell history stuff.
> >     As far as screen goes, you can dump the scrollback and search for
> >     your shell prompt, but that's about it.
> >     On Sun, Nov 07, 2021 at 09:29:12AM +0400, Vishal Priyatham wrote:
> >     > Hi team,
> >     >
> >     > We are using screen utility on linux server for one of our
> >     projects.
> >     > We have some issue related to our application and wanted to check
> >     what were
> >     > some of the commands run in the past which caused the issue.
> >     > Is there a way to know the commands run inside the screen session?
> >     >
> >     >
> >     > Regards,
> >     > Vishal
>

Reply via email to