Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-28-2007, 08:06 AM   #1
LQ Newbie
Registered: Feb 2007
Posts: 2

Rep: Reputation: 0
how can I record command history with times


I am a student running an experiment remotely on a linux machine. In the event of a problem I need to check what commands I may have sent to the computer (may be weeks in the past) which coincided with the time of the problem.

As well as a record of the commands I sent I also need to record the exact date/time each command was sent and the user that sent the command.

Does any one know of a good way of setting up such a monitoring system?



Last edited by cjreeve; 02-28-2007 at 08:29 AM.
Old 02-28-2007, 08:24 AM   #2
Senior Member
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: SlackWare > Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie stretch buster
Posts: 1,620

Rep: Reputation: 97

use tcsh

Happy Penguins!
Old 02-28-2007, 08:28 AM   #3
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can control the behaviour of command history by means of some environment variables. For example
HISTTIMEFORMAT - if set and not null determine the format of timestamp associated to an entry in the history (this is what you are looking for)
HISTFILE - is the name of the file in which command history is saved ($HOME/.bash_history by default)
HISTSIZE - is the max number of entries to store in the history, and so on...
Since you are looking for recording over a long period you may consider to backup the history file on a regular basis. Anyway it is a common practice to empty the history file every time you log out from a remote machine (for security reasons). In this case you may consider to automatically backup the history file every time you logout (e.g. append the current content of .bash_history to a file).

Edit: you can find all information related to history by issuing "info history".

Last edited by colucix; 02-28-2007 at 08:31 AM.
Old 02-28-2007, 08:56 AM   #4
LQ Newbie
Registered: Feb 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you. That has done the trick.




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
record CPU history mguleren Linux - General 1 03-10-2006 10:35 AM
History command amer_58 Linux - General 5 06-24-2005 12:26 PM
history clear command suguname Linux - Newbie 5 03-05-2005 09:32 AM
Command history? King4lex Linux - Newbie 4 09-03-2004 08:35 PM
command history log??? granny Linux - Newbie 3 02-11-2003 04:03 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:52 AM.

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