LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-06-2008, 07:16 AM   #1
GiotisSL
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Rep: Reputation: 0
"watch" command


hello Guys,
Can anyone help me with the "watch" command in Linux CentOS ?
I want to watch a user in my server.
I have full root access.

In FreeBSD the command is "watch -W pid#"

example:
ps aux
(the user's pid number is 1234)
# watch -W 1234


Is there a similar command in linux ?
 
Old 03-06-2008, 02:22 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Not so similar on the command side, but similar on the result side:

watch "ps aux | grep <pid> | grep -v grep"
 
Old 03-07-2008, 07:00 AM   #3
GiotisSL
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 0
I see nothing.

<<<
# ps aux
(pid# is 8558 and 8560)
# watch ps aux | grep 8558 | grep -v grep
#
[1]+ Stopped watch ps aux | grep 8558 | grep -v grep
# watch ps aux | grep 8560 | grep -v grep
#


Every 2.0s: ps aux | grep 8558 | grep -v grep Fri Mar 7 13:58:39 2008

root 8558 0.0 0.0 9008 2636 ? Ss 13:52 0:00 sshd: admin [priv]
>>>

Is there any command which I can see what a user is doing in real time ?
I mean when the user type "hello", my shell show me that the user type "hello".
 
Old 03-07-2008, 04:04 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by GiotisSL View Post
I see nothing.

<<<
# ps aux
(pid# is 8558 and 8560)
# watch ps aux | grep 8558 | grep -v grep
#
[1]+ Stopped watch ps aux | grep 8558 | grep -v grep
# watch ps aux | grep 8560 | grep -v grep
#


Every 2.0s: ps aux | grep 8558 | grep -v grep Fri Mar 7 13:58:39 2008

root 8558 0.0 0.0 9008 2636 ? Ss 13:52 0:00 sshd: admin [priv]
>>>
quotes are important.

watch ps aux | grep 8560 | grep -v grep

is not the same as

watch "ps aux | grep 8560 | grep -v grep"

... in the former, you're grepping the watch output. In the latter, you're grepping the ps output. So your example will do nothing. With quotes, you will see what you're looking for.

Quote:
Is there any command which I can see what a user is doing in real time ?
I mean when the user type "hello", my shell show me that the user type "hello".
This I don't know about, it doesn't seem reasonable (in that - what are you looking for? keystrokes? completed commands?, running programs?), but there's probably a way of doing something similar. :shrug:

Last edited by BrianK; 03-07-2008 at 04:12 PM.
 
Old 03-07-2008, 09:37 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by GiotisSL
Can anyone help me with the "watch" command in Linux CentOS ?
...
In FreeBSD the command is "watch -W pid#"
FreeBSD watch is very different than CentOS watch. AFAIK, they are not related and the naming is a coincidence.
  • FBSD: watch -- snoop on another tty line
  • CentOS: watch -- execute a program periodically, showing output fullscreen

The latter is akin to running an arbitrary command in a while loop. (And I don't know an analogous command for FBSD's watch in CentOS.)
 
Old 03-09-2008, 06:51 AM   #6
GiotisSL
LQ Newbie
 
Registered: Feb 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Is there any similar/same command ?
 
Old 04-10-2008, 04:15 AM   #7
gbellini
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
HI all,

digging around I found ttysnoop (www linuxhelp net guides ttysnoop)
I've not tried it yet, but I think it's worth a try

Cheers
 
Old 04-11-2008, 01:16 PM   #8
amrahd
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Yeah, here's a page describing how to get ttysnoop working on linux:

(add the http: / / bit before the following URL - this lame board wouldn't let me have a URL in my first post.)

sysadmingear.blogspot.com/2007/10/how-to-install-ttysnoop-on-linux.html

..and I was busy looking for a way to get the linux 'watch' command for freebsd - looks like someone else already took care of that: 'cmdwatch' tho I supose not many people on this board will care.

take care,
amrahd

Quote:
Originally Posted by gbellini View Post
HI all,

digging around I found ttysnoop (www linuxhelp net guides ttysnoop)
I've not tried it yet, but I think it's worth a try

Cheers
 
  


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
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Make "ls" command show colors without "--color=always" switch SharpyWarpy Linux - General 4 07-16-2007 11:00 PM
C Drive "/dev/hda1" accidently used in dd command at "of=" switch M D Linux - Software 4 04-26-2007 08:56 AM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-21-2003 11:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:01 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