- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Maintaining log for command being type on work...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 12:37 PM
09-18-2005 12:37 PM
Maintaining log for command being type on workstation
I was just wondering, is it possible to maintain a log of all command being type on a workstation. Even from remote login?
Thanks
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 01:19 PM
09-18-2005 01:19 PM
Re: Maintaining log for command being type on workstation
export HISTFILE=$HOME/.sh_history
The user commands will be in the .sh_history file. Now the above line assumes several things: the standard shell /usr/bin/sh, and the user actually logs in using something like telnet or rlogin. For non-standard shells like csh, a single command such as remsh, or non-standard connections such as CDE, there are diferent or additional steps.
Now to log everything including interaction with other programs, you can use the script command.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 01:49 PM
09-18-2005 01:49 PM
Re: Maintaining log for command being type on workstation
Thanks for the reply. Will this data be flushed whenever i logged off? Is there a way to prevent this. And is there a way to include a time stamp on when each command have been executed?
Regards
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 02:04 PM
09-18-2005 02:04 PM
Re: Maintaining log for command being type on workstation
The data in history file will not be removed when logging off.
Putting a time stamp for each file is not possible with this.
Script command can also be used to achive this for a particular session. script also has -a option to append to previous file.
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 02:14 PM
09-18-2005 02:14 PM
Re: Maintaining log for command being type on workstation
The history file specified by HISTFILE contains the latest commands you executed at your terminal. Every time you type a command at the prompt and press Return it is stored in this history file. HISTSIZE specifies the maximum number of commands stored in that file. For example:
HISTFILE=/users/test/.history
HISTSIZE=100
If you do not set these two variables in your .profile, the shell defaults to a file named .sh_history of 128 lines.
The history mechanism keeps continuous record of the most recent commands you have executed, even if you log out and back into the system many times or execute the commands in a subshell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 05:11 PM
09-18-2005 05:11 PM
Re: Maintaining log for command being type on workstation
Becasue with history, if you exceed the size, the older commands will be overwritten.
Further script will give you more detail output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 05:36 PM
09-18-2005 05:36 PM
Re: Maintaining log for command being type on workstation
do for:
each users:
# vi ~/.profile
insert -->
export HISTSIZE=1000
export HISTFILE=/.sh_history
the thing with .sh_history in each user profile is that they may amend that file as well.
if it is for auditing purpose, convert to trusted and turn auditing on.
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 05:43 PM
09-18-2005 05:43 PM
Re: Maintaining log for command being type on workstation
A similar thread you might want to look at it,
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=957735
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2005 06:20 PM
09-18-2005 06:20 PM
Re: Maintaining log for command being type on workstation
--- /etc/profile ---
set -o vi
export HISTFILE=/tmp/history_${LOGNAME}_$(date +'%d-%m-%y')
export HISTSIZE=2000
You can change HISTFILE setting.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2005 09:15 PM
09-19-2005 09:15 PM
Re: Maintaining log for command being type on workstation
I would suggest the following change to the .profile file:
TTY=$(tty)
TTYBASE=$(basename $TTY)
stty erase ^?
export HISTFILE=/.sh_history/$TTYBASE
This will create a new history file based on terminal.
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2005 10:06 PM
09-19-2005 10:06 PM
Re: Maintaining log for command being type on workstation
You need to add script in .profile script.
You can log all the session commands including session output with following:
1. In each user .profile , add the script command , So it will generate all the details of their session , with the file name.
Remember it will need additional space.
Line to add:
script $HOME/log/`whoami`.`date +%d%m%y"."%T`
So the file will have complete log of the user at that session , and close the log when he/she will logoff.. For details see: # man script.
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2005 10:10 PM
09-19-2005 10:10 PM
Re: Maintaining log for command being type on workstation
Little correction :
Check this out :
$ mkdir $HOME/log
$ script "$HOME/log/`whoami`.`date +%d%m%y"."%T"
Dont cat the output file .., you can check from another session.
Enjoy,
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2005 10:38 PM
09-19-2005 10:38 PM
Re: Maintaining log for command being type on workstation
It is better to keep history level itself when you are bothering about disk space also.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2005 07:34 AM
09-20-2005 07:34 AM
Re: Maintaining log for command being type on workstation
You may want to look at this thread (Is there a way to timestamp commnd history) for including a timestamp with the command.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=896650
Marlou