UnixServerAdmin

Server Administration & Management

Add timestamp to history

History is a linux shell command that list all the executed command on server. Default 1000 commands can be displayed in history. This command is use for invistigation purpose as which command was executed to solve the issue or to malfunctioning of server.

Initally output of history command is simple links.

989  date
990  history
991  history
992  w
993  top
994  w
995  cd /tmp
996  date

but adding timestamp it will provide you with an addational information of date and time of execution of command.
Which will help you inistigate as at what exact date and time command was executed.

To add time stamp add following.

Edit file /root/.bash_profile and add following.

export HISTTIMEFORMAT=”%F %T

Advertisements

February 5, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | 1 Comment