Determine Number of Processes Running


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Determine Number of Processes Running
# 1  
Old 12-17-2007
Determine Number of Processes Running

I am pretty new to unix, and I have a project to do.

Part of the project asks me to determine the number of processes running and assign it to a variable. I know how to every part of the project but determine the number of processes running.

How can I get just the number of processes running?

Thanks,
-Kevin
# 2  
Old 12-17-2007
ps -ef | wc -l
# 3  
Old 12-17-2007
Thanks a bunch!
# 4  
Old 12-17-2007
Quote:
Originally Posted by wayne1411
to determine the number of processes running and assign it to a variable.
To be precise:

Code:
var=$(ps -fe | wc -l)

assigns the value to variable var.

bakunin
# 5  
Old 12-17-2007
Do you need the -f option with ps?
(All it does is use up a load of cpu cycles gathering extra information about each process, that you will then throw away.)

Another option is to use sar to list the system process table utilization:
Code:
sar -v 5 5

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I find the number of processes running on root?

Is there a certain man command I'm missing here? I searched in ps but I couldn't find something that would give me the number of processes running on root. I only want to see the number of processes, not the processes itself. (2 Replies)
Discussion started by: l3monz
2 Replies

2. UNIX for Dummies Questions & Answers

Determine maximum allowable processes on a platform

Hello Unix gurus, I'm creating this analysis to determine whether the maximum allowable process is nearly reached then alarm the user with it. Can someone please help me on how I can determine the maximum allowable process that a platform can handle? BTW, below are the details that might be... (0 Replies)
Discussion started by: Jin_
0 Replies

3. UNIX for Dummies Questions & Answers

How do you print the number of processes that each user is currently running in Unix?

Ok, so I know there's a way to do this, but I've been trying to find out all afternoon with no luck. I think it should print out something like this: 1 bin 2 daemon 6 duo Where the numbers on the left are the number of processes being run by the user whose name is listed on the right. Is... (4 Replies)
Discussion started by: Duo11
4 Replies

4. Shell Programming and Scripting

determine the number of spaces

Here is a weird question :) i am trying to create a script written in bash that will create configuration files for nagios. As some of you aware is has to be written in the below format: define service{ option1 value1 option2 value2... (6 Replies)
Discussion started by: ppolianidis
6 Replies

5. Shell Programming and Scripting

determine the active processes on the system which are running since long time

Hi , Please help me shell script to determine the active processes on the system which are running since long time (2 Replies)
Discussion started by: itian2010
2 Replies

6. Shell Programming and Scripting

How to Control Number of Processes Running

Hi Is there a way to count how many processes a script has started, count how many of these have finished, and make the script wait if their difference goes over a given threshold? I am using a script to repeatedly execute a code (~100x) which converts 2 data files into one .plt which is in... (4 Replies)
Discussion started by: drbones
4 Replies

7. UNIX for Advanced & Expert Users

How to determine the number of NFS threads RUNNING on the system

Hi, Anyone can tell me how to get the number of NFS threads RUNNING on the system for Solaris 10? Someone told me for Solaris 9, the method is "echo "*svc$<svcpool" | adb -k. But, I've tried to google the method for Solaris 10 and did not find the corresponding method, please help... (1 Reply)
Discussion started by: wang.caiqi
1 Replies

8. Shell Programming and Scripting

Keep a certain number of background processes running

I've got a bit of code I'm trying to work on... What i want to happen is ... at all times have four parallel mysql dump and imports running. I found the follow code snippet on the forum and modified it to work by starting four concurrent processes but it waits until all four are done before... (7 Replies)
Discussion started by: dgob123
7 Replies

9. Programming

In C Program, determine if job is running

Is it possible to run the following Unix command in a C program and obtain results as to whether the job is running or not? ps -ef | grep 'job_name' | grep -v grep I'm fairly new at C and need to know what code I'd need in the C program. Thanks, in advance, for your assistance. (12 Replies)
Discussion started by: BCarlson
12 Replies

10. Shell Programming and Scripting

$A is a number / any other string? How to determine ?

I have a variable (say $A) and while passing it gets either a number or some other string. Now how can test (with if else) whether the variable is just a ne or something else ? Thanks a lot to all in advance C Saha (2 Replies)
Discussion started by: csaha
2 Replies
Login or Register to Ask a Question