LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-10-2007, 04:18 PM   #1
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Rep: Reputation: 16
Time Stamps for command history?


I occasionally run into a situation where I need to know more details about the command history than just the list of commands generated by the Bash history command.
Is there a (relatively simple) way to generate a more inclusive log file which works as follows:

1) Logs all commands issued by root,
2) Logs commands from multiple terminal windows simultaneously and to a single file,
3) Logs the commands in real time, in the order they were issued, and
4) Puts a date/time stamp on each command

That may be a lot to ask, but what I'm describing seems like a feature/function that a lot of system admins might find useful. Does a tool like this exist somewhere already?

Another related question:
Is there a setting that can be "switched on" which will include commands run from within Bash shell scripts in your Bash history file?

The only purpose to this is to help me find out exactly what happened in my server; primarily by seeing how commands issued by different administrators from different terminals might have interacted, especially if they were working on closely related parts in the system.


If it's important to include this, I'm running Fedora Core 6 & 7 and Red Hat Enterprise 4 & 5.
 
Old 09-10-2007, 05:41 PM   #2
rjwilmsi
Member
 
Registered: Mar 2005
Location: UK
Distribution: opensuse 12.2 x86_64
Posts: 563

Rep: Reputation: 38
As a partial answer: add
Code:
HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "
(or another accepted time format) to your .bashrc file to get a timestamp on all commands - note the trailing space included in quotes.
 
Old 09-11-2007, 02:52 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Also, the sudo util can log both successful and failed attempts, which may be useful.
 
Old 09-11-2007, 09:53 AM   #4
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by rjwilmsi View Post
As a partial answer: add
Code:
HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "
(or another accepted time format) to your .bashrc file to get a timestamp on all commands - note the trailing space included in quotes.
That's a good start!

Now, would there be a good way to snag new entries from the temporary history file (that each command shell keeps until it's closed) and drop them into a permanent file? As far as that goes, where is the temporary history file? And what's it's filename?




Quote:
Originally Posted by chrism01 View Post
Also, the sudo util can log both successful and failed attempts, which may be useful.
I don't understand here. Successful & failed attempts to do what? Enter a command?


Thanks to you both!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Time stamps following move to British Summer Time aikempshall Linux - General 2 03-30-2007 09:30 AM
Time Stamps Duplication indiancosmonaut Solaris / OpenSolaris 4 02-28-2007 11:30 AM
Samba time-stamps files incorectly k41184 Linux - Software 1 10-02-2005 09:24 AM
History command amer_58 Linux - General 5 06-24-2005 01:26 PM
Force samba client to enforce dos time stamps tisource Linux - Networking 2 02-06-2005 02:05 PM


All times are GMT -5. The time now is 06:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration