How to get users history as mail..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get users history as mail..
# 1  
Old 10-12-2011
How to get users history as mail..

Hi all,

Thanks in Advance,


i want to view my users commands, what commands they are using in their terminal like that, how to automate this history process daily.
# 2  
Old 10-12-2011
What's your system?
# 3  
Old 10-12-2011
Quote:
Originally Posted by Corona688
What's your system?

you mean Distro?

Centos 6

normally we can view commands using history command, but how can we automate this process as daily, is it possible to get the command details in daily basis?
# 4  
Old 10-12-2011
Quote:
Originally Posted by anishkumarv
you mean Distro?

Centos 6
There's more OSes than Linux. Look at the forum list and you'll see a variety of UNIX and UNIX-like systems.

So your system is Linux, and your distro is Centos.
Quote:
normally we can view commands using history command, but how can we automate this process as daily, is it possible to get the command details in daily basis?
You could put it into a cron job. crontab -e and put this into your cron table:
Code:
# 5 minutes after midnight, every day
5 0 * * * /path/to/script.sh

which will run your history script every day. Beware that cron's environment is minimal, you might need to set a better PATH in your script.
# 5  
Old 10-12-2011
:-( :-( :-( hmm Iam asking how to get the commands , History is the only way?? i know Crontab and all.
# 6  
Old 10-12-2011
history, the command, is a shell builtin, not an external thing. Some shells don't have it at all. How to get at the data from outside depends on what shell they use.

If you use the bash shell, the history data will be in ~/.bash_history. You can just read that.

~/.bash_history gets updated by bash only when the user quits their shell.
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 10-12-2011
Be advised that the location of the history file for both Kshell and bash is controlled with the HISTFILE environment variable. If a user sets this, (I do, and most people I work with do), you might not find anything or everything that you expect. Further, history won't have any details about commands that were executed from scripts started from the command line, nor will it have any information about what users are executing from at or cron.

Depending on what your goal is, you might consider using system accounting to track how your systems are being used. See the man pages for accton which turns accounting on/off, sa which summarises accounting information and lastcomm which lists the accounting information by user and/or by command and shows execution time and elapsed time (information you'll not get by looking at the history).

System accounting will show all commands run by all users, not just what was run from the command line.

Link to lastcomm manpage which should reference other related pages:
Man Page for lastcomm (All Section 1) - The UNIX and Linux Forums

Last edited by agama; 10-12-2011 at 10:34 PM.. Reason: typo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code: archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (0 Replies)
Discussion started by: rehantayyab82
0 Replies

2. Shell Programming and Scripting

History of all the users in single file with command , date . time , ip and user

HTML Code archive_history() { HISTORYOLD=${HISTFILE}.archive CURTIME=`date` CURTTY=`tty` IP=$(echo $SSH_CLIENT | awk '{print $1}') if ; then echo "#-${HOSTNAME}-- ${CURBASHDATE} - ${CURTIME} ($CURTTY) ${USER} ${IP}----" >> $HISTORYOLD history... (2 Replies)
Discussion started by: rehantayyab82
2 Replies

3. Shell Programming and Scripting

Tracking users through history command

Hi folks, I have the basic query that there are 3 unix boxes having their individual access now in my team there are 4 members who are using the same credentials to access those 3 boxes through putty ssh from their windows desktop , now if i want to check which 4 members have executed the... (1 Reply)
Discussion started by: punpun66
1 Replies

4. Shell Programming and Scripting

Shell Script to zip users cmd history log files

I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents: Part A # more user_history_Feb cp -p /var/log/user_history/*history... (6 Replies)
Discussion started by: hedkandi
6 Replies

5. UNIX for Dummies Questions & Answers

The history command: See other users command history

Can anyone tell this: If two users are logged into the same server from different locations. Is there a way to see the history command of the other user? I tried the history command, but it is showing me only the commands I used. Thanks in advance for your help. Iamnew2solaris (1 Reply)
Discussion started by: iamnew2solaris
1 Replies

6. Shell Programming and Scripting

Shell script for to view all users & groups history in root

Dear All, I want to know all users & group history in one file, for root terminal through shell or any other option (5 Replies)
Discussion started by: kpoobathi
5 Replies

7. Shell Programming and Scripting

Send e-mail to users

Dear all, The perl script to send e-mail is working in my current script. #This part of the script will send the email notification my $to='mohamed.rahman@noridian.com'; my $from='xyz@hotmail.com'; my $subject='POS_CODES_38 DATA LOADED SUCCESSFULLY.'; my $message='The total no. of files... (2 Replies)
Discussion started by: msrahman
2 Replies

8. Shell Programming and Scripting

stop users from running 'history -c' in Linux

Hi All, My question is how can i stop my users on system from deleting their history. How can i stop the users from running 'history -c'. I have searched thoroughly on the forum but didn't find any satisfactory solution to the problem. kindly help if you any suggestions Thanx in... (3 Replies)
Discussion started by: xander
3 Replies

9. HP-UX

How to enforce users not to modify their command history.

As a system administrator. sometimes we see the users are trying some commands dangerous for the system health and remove them from their individual coomand history file. How it is possible to enforce that the normal usres will will not be able to modify the history. Thanks in advance. Partha (4 Replies)
Discussion started by: partha_bhunia
4 Replies

10. UNIX for Advanced & Expert Users

tcsh history for several users

Hi all! I have a nice challange for you today :) I have several users that use "tcsh" the problem is that they all have the same "home_dir" (application reasons...), now... as far as i know (correct me if i'm wrong) every user have an history file in his "home_dir" that calls ".sh_history" or... (0 Replies)
Discussion started by: eliraza6
0 Replies
Login or Register to Ask a Question