using history command with ssh and getting output with time stamps

Solution 1:

Two things:

  1. You need to also export e.g.

    HISTTIMEFORMAT='%F %T '
    

    to set display command history times.

  2. If you have not set the HISTTIMEFORMAT environment variable when using a session, the command times will not be saved and you will then of course not be able to see them. By default the current time will be printed as the command time for every command lacking a time indicator.

If you look at the ~/.bash_history file you can see if you have had time stamps activated for the sessions. Every other line will then start with a # followed by the epoch time of the next command.