Friday, November 7, 2008

Saving History To Another File

santo asked: "Is there any way to save the history command automatically in any other file in every 5min, can we do it through crond,if yes plz do so for me"

This is quite simple and you don't need cron. In 3 easy steps...

First, add shopt -s histappend to your bashrc to get history appended on bash session exit.

Next, make sure you have export HISTCONTROL=erasedups there to have no duplicate entries.

Finally use a large number in export HISTSIZE= i.e. 25000.

This will give you a large .bash_history file that you can search and back-up as needed.