Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-03-2010
Registered User
 

Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Homemade activity monitor-ish

Hello - I didn't find this with search, but I'm guessing it's out there somewhere. Apologies for reposting if that's the case.

I'm shell scripting on a 10.5.8 Mac.

I want to make a program that runs in the background and periodically logs computer use, storing things like - cpu usage, programs running, etc. I know I can get the pid of the most recently called process with $!, but is there a way to get the pid of any arbitrary process, or even to see all pids in use at one time? Do all processes have single, unique pids?

Is it possible to see the number of windows open at any one time?

Thanks.
Sponsored Links
    #2  
Old 09-03-2010
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 

Join Date: Sep 2007
Location: Germany
Posts: 5,193
Thanks: 47
Thanked 280 Times in 267 Posts
Yes, all processes have a single unique pid. The ps command might help you. Not sure if this is the same switches on Mac, but you can get for example process stati with:

Code:
ps aux

where the STAT column might be interessting for you. The values are explained in the man page for ps so you might grep for the ones you'd like to see.
Where you can see the number of open windows, I do not know. But maybe you can find them in some X log or also as processes or threads.

Last edited by zaxxon; 09-06-2010 at 04:53 AM.. Reason: typo
Sponsored Links
    #3  
Old 09-03-2010
Registered User
 

Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks so much. ps looks great.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Commands to monitor other user's activity Sotau UNIX for Dummies Questions & Answers 2 11-30-2009 10:23 AM
How to monitor system activity while executing tests smovla Shell Programming and Scripting 2 06-22-2009 12:06 PM
Tool to monitor user activity nana UNIX for Dummies Questions & Answers 3 07-15-2005 11:26 AM



All times are GMT -4. The time now is 04:03 AM.