LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-14-2007, 08:07 PM   #1
Kvetch
Member
 
Registered: Mar 2004
Posts: 35

Rep: Reputation: 15
Write history to .bash_history on reboot


I run Gentoo and was wondering if anyone knows how can I get bash to dump my current shell cli history to .bash_history when I type reboot or shutdown. When I bounce my box if I don't exit the shell then it doesn't write my command history to the bash_history. I had this issue with Linux From Scratch too.

I was hoping it would be a setting in bashrc, or /etc/profile but I can't find anything that stands out to writing the history on a init. Since I had this issue with LFS I looked there and found this.
http://linuxfromscratch.org/pipermai...ne/060297.html

I have no clue on how to get it to do the SIGHUP. I suppose I would need to grab the source for shutdown, modify it and recompile shutdown. Anyone else have any better suggestions? Is there a way I can get the initlevel to run some commands before issuing the init 6?

Thanks,
Nick
 
Old 03-14-2007, 08:32 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Try adding this to the end of your ~/.bashrc:

# append shell commands to the history file as they are
# used, instead of waiting until shell exit to write
# to the history file.
shopt -s histappend

# when displaying the shell prompt, write the previous
# command line to history file.
PROMPT_COMMAND='history -a'
 
Old 03-14-2007, 08:43 PM   #3
Kvetch
Member
 
Registered: Mar 2004
Posts: 35

Original Poster
Rep: Reputation: 15
Thanks BigRigDriver, I guess that is going to be my best bet. I saw that as an option in the LFS post but wasn't sure if there was some other way around it that I might be missing.

I appreciate it.

-Nick
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.bash_history t3gah Linux - Software 2 05-05-2005 03:45 AM
I clean history in Konqueror but when I reboot it reappears. pujolasdf Linux - Software 2 03-18-2005 04:21 PM
hard drive write causes reboot eastsuse Linux - Newbie 2 05-14-2004 10:49 AM
bash_history linj Linux - Software 6 08-08-2003 10:13 AM
.bash_history gone togeno Linux - Security 3 06-30-2003 07:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:52 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration