how to store time in .bash_history file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to store time in .bash_history file
# 1  
Old 02-18-2012
how to store time in .bash_history file

Hi - user commands are written in . bash_history of that user when he logs out. my bash_history file shows. not sure what that number means

#1329618972
ls -la
#1329618978
ls
#1329618980
ls -la

my bash_profile looks like this

PATH=$PATH:$HOME/bin
export PATH
export HISTTIMEFORMAT='%F %T '
export HISTSIZE=200000

I logged and logged out multiple times as the user but I am not able to get time in bash_history. Am I missing out something ?

Thanks,
# 2  
Old 02-18-2012
Those are unix timestamps -- number of seconds past midnight January 1st, 1970. The first timestamp in your post is 2012/02/18 21:36:12.
This User Gave Thanks to agama For This Post:
# 3  
Old 02-18-2012
Thanks agama I was scratching my head as what that number was. How do I get the current time stamp instead of seconds passed from 1970.

Thanks,
# 4  
Old 02-19-2012
I don't use bash, so this is a guess. The timestamp in the file will always be unix time. The format string is what bash uses when you execute the history command such that commands are printed with the timestamp that was saved.

This allows you to change the format, without the need for bash to update all of the previously written timestamps in the file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to get the "history" command to show all that is in the .bash_history file?

I am using the bash shell. When I view my recent command history using the "history" command from the prompt, it only shows me the commands starting at #928. The commands I need are earlier than that, but I can't figure out how to make the other 927 display. They are in my .bash_history... (1 Reply)
Discussion started by: Twinklefingers
1 Replies

2. UNIX for Dummies Questions & Answers

Why does SSH store the fingerprints of remote host when connecting for the first time?

I was wondering why does ssh store the fingerprints of remote host when connecting for the first time? I will appreciate a detailed response, can't figure it out. (2 Replies)
Discussion started by: ChiefGandalf
2 Replies

3. UNIX for Advanced & Expert Users

How to recover .bash_history?

rm -rf .bash_history some one ran rm -rf .bash_history on my Linux server(SUSE),I can see this command being run in current history, but I want the OLD history as well,can I recover the old history back. (9 Replies)
Discussion started by: Ankit Bansal
9 Replies

4. Red Hat

Store time stamp for .csh shell users

How do I store the time stamps of each command executed for C shell users? However, I am able to set this for Bash users with this command: export HISTTIMEFORMAT="%F %T " This is how a typical .cshrc look like for a Cshell user: # more .cshrc # necessary to get hostname... (3 Replies)
Discussion started by: hedkandi
3 Replies

5. UNIX for Advanced & Expert Users

.bash_history modification

Hi Experts, I know my question would be strange but i need to understand how the .bash_history file is logging user actions (the mechanism) and if possible modify it to include also the date/time of every action done by the user. Sample file: # more .bash_history ssh <IP address> -l axadmin... (3 Replies)
Discussion started by: Dendany83
3 Replies

6. Shell Programming and Scripting

.bash_history

Dear All, I am creating users on our servers. the .bash_history supposed to store all the commands entered by the user. My question is, how can I prevent the user himself from editing or viewing this file? I have tried chaning the owner of the .bash_history to be the root user but... (5 Replies)
Discussion started by: charbel.n.s
5 Replies

7. UNIX for Advanced & Expert Users

.bash_history

During the course of the session before I logout I see some of the commands listed from my previous session but not from my current session and after I logout and log back in I see the commands which I ran before logging out. Does the .bash_history stay in the buffer or someplace else then? ... (2 Replies)
Discussion started by: jacki
2 Replies

8. UNIX for Dummies Questions & Answers

Change .bash_history to another one

we need the help to change .bash_histroy file in root ,(i.e) we want to save the histroy for .temp.txt for permenently. how to do?? Help us (1 Reply)
Discussion started by: thakshina
1 Replies

9. UNIX for Advanced & Expert Users

Find and store files based on FileName and Modified Time

Hi, I am currently using the following command: files=(ls enuCPU??.????.exp ntuCPU??.????.exp) I need to now change the commmand to store the file names of files that have been modified before datetime equal to say '02/16/2008 20:30:00' What could I use? (2 Replies)
Discussion started by: edisonantus
2 Replies

10. UNIX for Advanced & Expert Users

.bash_history

Question for all sysadmins. How do you keep track of what commands each user uses on his account. I thought an easy way is to monitor .bash_history, however those files can be "edited" by the user. Is there a permission combination that will allow the shell to record to it but yet they can't edit... (12 Replies)
Discussion started by: jason6792
12 Replies
Login or Register to Ask a Question