LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 10-17-2008, 07:02 PM   #1
idleBrain
LQ Newbie
 
Registered: Jan 2008
Posts: 5

Rep: Reputation: 0
difference between "ps" and "top" command


hi all,

i am a newbie and have a very silly question about the difference between "ps" and "top".

i have a code which takes a long time to execute. initially the executable shows when i type "ps -a" or "ps -ef". but, after some time the executable disappears from this list. however, when i type "top" the executable shows up over there.

my question is: when does some executing process shows up in "top" only and not in "ps" ?

thanks in advance.
 
Old 10-17-2008, 08:41 PM   #2
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
Have you tried piping the output of ps to grep? It would be like this:
Code:
ps -ef | grep <appname>
"ps -a" would certainly not show all processes, but ps -ef would - although some might be off the screen as ps doesn't wrap (unless you were to pipe it through less or something, like "ps -ef | less")
 
Old 10-18-2008, 03:38 AM   #3
idleBrain
LQ Newbie
 
Registered: Jan 2008
Posts: 5

Original Poster
Rep: Reputation: 0
yes, i have tried ps -ef and also piping the output to less.
but still no luck
 
Old 10-18-2008, 06:03 AM   #4
maniannam
Member
 
Registered: Dec 2007
Location: India
Distribution: fedora 11
Posts: 64

Rep: Reputation: 15
Hi,

What are the process having your machine?

which is need for the machine to alive and dependence up on your running application. This type of process only that all machine having. At the time some of the process only running not all process.

For example: init process should need for your machine because that is the main process in linux. This process not running continuously but its need to alive the machine.

you will start the xmms application(mp3 player). For this case, this application runs continuously. some time this process also not running continuously.

Finally all the process not running all the time.


'ps' command showing all process by time wise. which is having the all process. Its not care about the process is running or sleeping.

example:

[root@maniannam ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
</b>root 1 0 0 Oct17 ? 00:00:01 init [5] </b>
root 2 0 0 Oct17 ? 00:00:00 [kthreadd]
root 3 2 0 Oct17 ? 00:00:02 [migration/0]
root 4 2 0 Oct17 ? 00:00:33 [ksoftirqd/0]
root 5 2 0 Oct17 ? 00:00:00 [watchdog/0]
root 6 2 0 Oct17 ? 00:00:01 [migration/1]
root 7 2 0 Oct17 ? 00:00:25 [ksoftirqd/1]
root 8 2 0 Oct17 ? 00:00:00 [watchdog/1]
root 9 2 0 Oct17 ? 00:00:00 [events/0]
root 10 2 0 Oct17 ? 00:00:00 [events/1]
root 11 2 0 Oct17 ? 00:00:00 [khelper]
root 63 2 0 Oct17 ? 00:00:00 [kblockd/0]

mani 8927 1 0 13:56 ? 00:00:00 /bin/sh /usr/lib/firefox-2.0.0.16/firefox
mani 8946 8927 0 13:56 ? 00:00:00 /bin/sh /usr/lib/firefox-2.0.0.16/run-mozilla.sh /usr/lib/firefox-2.0.0.16/firefox-bin
mani 8951 8946 5 13:56 ? 00:04:10 /usr/lib/firefox-2.0.0.16/firefox-bin
mani 8965 1 0 13:56 ? 00:00:00 /bin/sh /usr/lib/thunderbird-2.0.0.16/thunderbird
mani 8969 8965 0 13:56 ? 00:00:00 /bin/sh /usr/lib/thunderbird-2.0.0.16/run-mozilla.sh /usr/lib/thunderbird-2.0.0.16/thunderbird-bin
mani 8974 8969 1 13:56 ? 00:01:09 /usr/lib/thunderbird-2.0.0.16/thunderbird-bin
mani 9117 8951 39 14:20 ? 00:20:34 /usr/lib/nspluginwrapper/npviewer.bin --plugin /usr/lib/mozilla/plugins/libflashplayer.so --connection /org/w
<b>root 9269 8888 0 14:56 pts/1 00:00:07 /usr/libexec/xmms</b>
root 9317 8888 0 15:12 pts/1 00:00:00 ps -ef


'top' command showing running process in the top order. That's why you can see the some of the process in the first line after some time it will go second or third its dependences on the process status.

S- sleeping process
R- Running process
D- going to die

example :
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
9117 mani 20 0 96212 29m 9148 S 9 1.0 20:51.01 npviewer.bin
9325 mani 20 0 55004 6900 5260 R 7 0.2 0:04.04 xmms
2519 root 20 0 391m 75m 11m R 3 2.5 52:32.31 X
8951 mani 20 0 273m 101m 22m S 1 3.3 4:17.66 firefox-bin
7 root 15 -5 0 0 0 S 0 0.0 0:25.69 ksoftirqd/1
9323 root 20 0 2272 1020 784 R 0 0.0 0:00.31 top
1 root 20 0 2112 656 572 S 0 0.0 0:01.50 init
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd


Please forgive me for my english. I hope it will helpful......


Regards,
maniannam
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 05:08 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
Suggestion: for "subscribed threads" & "top of page" buttons Old_Fogie LQ Suggestions & Feedback 7 07-10-2006 06:10 PM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 10:40 AM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 02:30 PM


All times are GMT -5. The time now is 10:15 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration