Answered by the Webhosting Experts

How to add timestamp to history command?

history command lists all executed command on server.

By default output of command is as follows:

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

 

After you add timestamp, it will show you a detailed output with date, time and command.

SSH to server as root and edit file /root/.bash_profile with your favorite editor and add following line:

Export HISTTIMEFORMAT="%F %T "
 
Now logout and login again and execute history command, you will see
 
Detailed output as follows:-
 
root@Server[~]#history
 
19  04/25/10 08:26:48 hostname
20  04/25/10 08:46:34 history
21  04/25/10 08:46:48 w
22  04/25/10 08:46:50 date
23  04/25/10 08:46:52 cal
24  04/25/10 08:46:53 ls -la
25  04/25/10 08:46:55 top
26  04/25/10 08:47:11 tail -f /var/log/messages
27  04/25/10 08:47:29 history

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here at: support@hivelocity.net. We are also available to you through our phone and live chat system 24/7/365.