Saturday, April 27, 2024
456
rated 0 times [  456] [ 0]  / answers: 1 / hits: 598771  / 2 Years ago, fri, april 22, 2022, 6:45:46

Is there any way I can see at what time the commands were executed from the bash history? We can see the order but is there any way I can get the time also?



Bottom-Line: Execution time in the Bash history


More From » command-line

 Answers
6


Press Ctrl+Alt+T to open a terminal, then run one of the commands below:



HISTTIMEFORMAT="%d/%m/%y %T "  # for e.g. “29/02/99 23:59:59”
HISTTIMEFORMAT="%F %T " # for e.g. “1999-02-29 23:59:59”


To make the change permanent for the current user run:



echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc  # or respectively
echo 'HISTTIMEFORMAT="%F %T "' >> ~/.bashrc
source ~/.bashrc


To test the effects run:



history


For more info see man bash or An A-Z Index of the Bash command line for Linux.



For commands that were run before HISTTIMEFORMAT was set, the current time will be saved as the timestamp. Commands run after HISTTIMEFORMAT was set will have the proper timestamp saved.


[#27966] Friday, April 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cretanol

Total Points: 320
Total Questions: 99
Total Answers: 115

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
cretanol questions
Fri, Dec 2, 22, 13:30, 1 Year ago
Thu, Dec 8, 22, 03:00, 1 Year ago
Mon, Aug 1, 22, 03:21, 2 Years ago
Fri, Sep 24, 21, 16:28, 3 Years ago
Sun, Apr 24, 22, 06:37, 2 Years ago
;