I'm running a bash file to obtain data on what system processes are running (i.e netstat, syslog, arp etc). All's going well except for the history. I'm trying to save the history to a text file with
cp ~/. bash_history $path/filename.txt
Unfortunately this doesn't give me the complete history. If manually input the command
history > /media/root/usb/filename
I get a completely different result. My aim is to automate the whole process under the one bash file, is there a way of doing this. Also i'd ideally like the date and time with the history.
cp ~/. bash_history $path/filename.txt
orcp ~/.bash_history $path/filename.txt
I'm not seeing a very big difference between my.bash_history
andhistory
history
doesn't write to.bash_history
until you log out. So.bash_history
should include everything except your current session, wherehistory
would include everything.history -a; cp ~/.bash_history $path/filename.txt
to ensure that your bash_history is written to just before you perform the copy.