LinuxQuestions.org
Help answer threads with 0 replies.
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 05-15-2013, 08:22 AM   #1
skhalidamin
LQ Newbie
 
Registered: Sep 2012
Posts: 2

Rep: Reputation: Disabled
top command


top -u khalid -n 1 -stats pid,command
...this command is used to get the currently running processes in system by extracting two columns pid and command---but this is used in macontosh....in linux we dont have any stats command----so plz help me to get stats equivalent command in linux..
 
Old 05-15-2013, 08:50 AM   #2
VANK1989
LQ Newbie
 
Registered: May 2013
Location: India
Posts: 6

Rep: Reputation: Disabled
Hi,

You can use the bellow commands to list all process running in the linux server.

========
top
ps aux | grep all
pstree
=======

Please get back to us if you need any further queries.

Regards,
Vank!

---------- Post added 05-15-13 at 08:50 AM ----------

http://www.cyberciti.biz/faq/show-al...sses-in-linux/
Quote:
Originally Posted by VANK1989 View Post
Hi,

You can use the bellow commands to list all process running in the linux server.

========
top
ps aux | grep all
pstree
=======

Please get back to us if you need any further queries.

Regards,
Vank!
 
Old 05-15-2013, 08:57 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Just try:
Code:
~$ ps -aeu khalid -o pid,cmd,stat
For more options, explore manual of ps cmd see here.
 
1 members found this post helpful.
Old 05-15-2013, 09:41 AM   #4
skhalidamin
LQ Newbie
 
Registered: Sep 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Actually this is a java code which is using it....
i need top to get the process list ...but i need only 2 columns pid and command.
Process process = Runtime.getRuntime().exec("top -u khalid -n 1 -stats pid,command")
 
Old 05-15-2013, 09:58 AM   #5
VANK1989
LQ Newbie
 
Registered: May 2013
Location: India
Posts: 6

Rep: Reputation: Disabled
Hi,

Please try bellow command.

=======
ps aux | grep PID | head
======

Thanks!

Regards,
Vank!
 
Old 05-15-2013, 11:13 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I feel certain that ps gets its information from the /proc filesystem, and that it makes the most sense for you to do so as well. Under /proc, any directory which has a name composed solely of decimal numerals is an entry for an existing process, and the respective PID is given by the directory name. Within the directory for each process is a pseudo-file, 'cmdline'. Reading that file will give you the commandline that was used to launch the process. Iterating over the /proc directory and getting all of the respective cmdline files gets you the information in the most direct form. Can be done in any programming language that can read from files and directories.
--- rod.
 
Old 05-15-2013, 11:41 AM   #7
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,245
Blog Entries: 11

Rep: Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287Reputation: 2287
Quote:
Originally Posted by VANK1989 View Post
ps aux | grep all
is no good here (1 hit and that's the grep I just used)
Code:
ps aux | grep all | grep -v grep
will show. YMMV?

http://www.ibm.com/developerworks/ai...y/au-lsof.html
try processing against
Code:
pstree
or
Quote:
Originally Posted by shivaa View Post
Code:
~$ ps -aeu khalid -o pid,cmd,stat
+1 shivaa for that.
 
  


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
Top Command help malickhat Linux - Newbie 5 10-12-2011 05:51 PM
LXer: Can You Top This? 15 Practical Linux Top Command Examples LXer Syndicated Linux News 0 01-09-2010 09:42 PM
Finding the top CPU-using processes? "top" command does not help... catalytical Linux - Server 1 04-06-2009 04:50 PM
top command Volcano Programming 18 10-15-2008 10:02 PM
Top command mtnpaul Linux - Software 2 04-17-2008 04:25 AM


All times are GMT -5. The time now is 03:55 PM.

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