0

Let's say you have a bash terminal open, in which you have typed a lot of commands, many of which are probably not yet saved in $HISTFILE. Additionally, let's say that you have a long running command running in that terminal, so you can't really stop this command to issue history -a to append new entries to/flush to the $HISTFILE.

My question is: is it possible to trigger the equivalent of history -a, in a bash shell which has a process running inside it, remotely - that is, just by knowing this shell's PID? Maybe there's some sort of signal that can be issued to the running bash process - but could I issue that via bash or standard tools?

(I'm trying to develop a Python psutil script which will save settings of all my open bash terminals and their history files, and for this to make sense, I guess all these bash processes need to flush their unflushed lines to respective $HISTFILEs, before the script copies these files; and some of these shells may have long-running processes in them. So if this "remote history flush" is doable from another bash instance, then it will be doable via Python too...)

sdaau
  • 6,778
  • see: https://unix.stackexchange.com/questions/341534/is-it-possible-to-view-another-shells-history/489405#489405 – sdaau Dec 17 '18 at 04:53
  • 1
    Can't this long running command be even momentarily stopped for a Ctrl-Z and bg? – muru Dec 17 '18 at 05:12

0 Answers0