I need a script that captures the contents of the linux command line history file, for auditing purposes. I noticed that when i use the history command in a script that outputs commands to a file, it doesn't work. My script looks like this:
[root@test ~]# cat 2baseline.sh
exec >> $BASEFILE 2>&1
tail -n 1000 /var/log/messages
All the commands output fine, except the history command. Can someone suggest on alternative way for the history file to be copied to a file?
thanks very much.