Add date to bash history

Need to add date to bash history, knowing when some commands were fired.

Before:

root@host# history

1 ifconfig
2 ifup eth0
3 ifconfig
4 shutdown -r now

 echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile

Restart ssh session.

After:

1 Dec/28 – 12:22:13 ifconfig
2 Dec/28 – 12:23:37 ifup eth0
3 Dec/28 – 12:24:51 ifconfig
4 Dec/28 – 12:25:45 shutdown -r now

DISCLAIMER: If you use the copy/paste thing, watch out for the qquotes1   and replace them with squotes1

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: