Need help on below script. Requirement is to capture command line history in a file with specific date and time of command, when it was execute. Below script capture history with date and time but it also assign current date and time for older commands. also I want to extend the script to take incremental backup of history output file.
#!/bin/bash
. ~/.bash_profile
HISTFILE=~/.bash_history
set -o history
history >/home/user/hist_date "+%d%b%y%T"