I am working on a script that will help the sysadmins on our team monitor what's going on in other terminals by other logged in users.
One thing I'm stuck on right now is how to view what commands have been typed. I realize that the history doesn't get saved until the user exits or types history -a
, but there has to be a way to view what's currently in the history, even if it's stored in memory somewhere.
Is it possibly saved somewhere in /proc/${pid_of_users_bash}
? I tried to type a command echoing a unique string (EG: echo "foobarbaz"
, then greping for foobarbaz through any flat files within the associated /proc/PID
directory, but no luck.
If anyone has a solution that doesn't involve setting thePROMPT_COMMAND
or setting the histappend
(like these), that would be greatly appreciated.
PROMPT_COMMAND
when logging in there. It also messes withset -x
which I have turned on by default... – Kusalananda♦ Oct 2 '17 at 20:29