LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-15-2008, 04:38 PM   #1
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Rep: Reputation: 16
Question Question about bash history temp files


I'm running Fedora 8, but this question would apply to pretty much any Linux/UNIX system:

Occasionally, I'll have a bash terminal session open when something happens that cuts it off from contact with the server and crashes the session. It's especially annoying when it's something I did that caused the crash and I can't review the commands I issued that caused it. (The permanent .bash_history file only gets updated if you exit the terminal session cleanly.)

Where does Linux put the temporary file containing the commands from your current bash session? I haven't been able to find anything that looked like the right file, but it has to be there somewhere. Even if it's stored in RAM, it still has to exist as a file of some sort.

Thanks!
 
Old 05-15-2008, 05:07 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,132
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
If the process didn't get a chance on exit to write out history to $HISTFILE then parts of it may reside in Purgatory (memory, swap) but more likely in Bit Paradise. I doubt it's worth chasing, next time better run from inside 'screen' with history enabled or under a logging shell wrapper like 'rootsh'.
 
Old 05-15-2008, 05:30 PM   #3
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Thumbs up

Thanks unSpawn. I completely agree that chasing fragments of it after the fact would be pretty much useless! The reason I was asking about a file name/location in particular is that I was thinking of setting up some sort of script to copy the session data on the fly, straight from the temp file to a permanent (ie. recoverable) file as it appeared in the temporary location.

What's this 'screen' you mentioned? If possible (and practical), I'd like to set up something that runs automatically any time a shell window opens, and saves the data to a consistent location.

Thanks again!

Quote:
Originally Posted by unSpawn View Post
If the process didn't get a chance on exit to write out history to $HISTFILE then parts of it may reside in Purgatory (memory, swap) but more likely in Bit Paradise. I doubt it's worth chasing, next time better run from inside 'screen' with history enabled or under a logging shell wrapper like 'rootsh'.
 
Old 05-16-2008, 12:04 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
http://www.chovy.com/personal/linux-...tility-screen/
 
Old 05-16-2008, 05:53 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,132
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
Quote:
Originally Posted by WingnutOne View Post
I was thinking of setting up some sort of script to copy the session data on the fly, straight from the temp file to a permanent (ie. recoverable) file as it appeared in the temporary location.
If you know Bash you know session history is only written on exit. A shell wrapper like 'rootsh' takes care of it as it writes whatever appears on screen to file or syslog. Another alternative could be to use (recompile) Bash with a logging patch, Anotatla had one and the Honeypot project still hosts a version, but its logging is not as easy or complete as 'rootsh' IIRC. Screen comes in handy for resuming (remote) sessions and it has logging too (CTRL+A,SHIFT-H). If one child (shell) crashes you should be able to open another window. Using rootsh is easy: install 'rootsh' (in /bin, where your other shells reside), add it to /etc/shells, then 'chsh' and you're set. Automagically logging on user login.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Temp bash shell for root stefaandk *BSD 6 08-07-2007 02:07 AM
Where's my bash history? subnet_rx Red Hat 6 02-07-2007 06:35 PM
need someone to look into this bash history bytez Linux - General 7 10-16-2006 10:26 PM
bash history jasonnth Linux - Software 7 08-08-2006 01:35 AM
Bash History ukndoit Linux - Security 2 10-16-2003 09:02 AM


All times are GMT -5. The time now is 02:17 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration