Re: file .bash_history

Arkadiusz Drabczyk <[email protected]> Wed, 11 Nov 2015 13:57:11 +0000 (UTC)
Newsgroups gmane.linux.slackware
Organization Daddy, why doesn't this magnet pick up this floppy disk?
Message-ID <[email protected]>
On 2015-11-11, Philippe Delavalade <[email protected]> wrote:
> Hi all.
>
> I hope I'll be claer because my english is not fluent :-)
>
> When I'm logged as USER, for instance, on tty2, if I do "logout", the file
> .bash_history is updated (.bashrc contains line 'shopt -s histappend').
>
> But when I'm halting the system, this file is not updated. What can I do ?
>
> May be I can add some lines in /etc/rc.d/rc.local_shutdown but I don't know
> which ones :-(
>
> I examined /etc/rc.d/rc.6 but this didn't help me.
>
> Thanks for help or suggestions.
>

Something like this will do the job:

$ PROMPT_COMMAND="history -w; $PROMPT_COMMAND"

It will not overwrite your current $PROMPT_COMMAND and make Bash
append current history to $HISTFILE after every command execution and
not only when a shell exits.

BTW, be aware of difference between login and non-login shells.  When
you log in for an interactive session in tty ~/.bashrc is not read and
the above should be added to ~/.profile.

-- 
Arkadiusz Drabczyk <[email protected]>


_______________________________________________
slackware mailing list
[email protected]
https://mailman.lug.org.uk/mailman/listinfo/slackware