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 »

  1. Thanks for sharing…
    This is what I was searching from last few days…

    Thanks again… Please share the post for how to send root login alert for admin email…

    Comment by test | August 26, 2012 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: