Command to find out "count" of running process ?

Hello Experts,

Can any one help me out to find the command to get "count" of number of processes running in system.

Basically i want to write one crone job to kill some process which making my system hanged. so have to do following things.

1) Find out the number of processes is running.
2) If count reach to some threshold value , use kill command to kill those processes.

I need to know how can I find out count of running processes & crone tab job to run that command.

Thanks in Advance!

ps | wc -l

The output and option format of ps varies across systems, so you will need to consult your local man ps to figure out how exactly to get all the processes.

How do you propose to figure out which ones to kill? Take care not to kill any crucial system processes. This sounds like you need to work out the requirements in more detail.

This also sounds like homework, actually. Is it?

Thanks era,

First i will be using count command , After that i will do grep command to find out the processes which needs to be killed.

but all that i have to put in crontab job , So you have any document or pdf file through which i can start working on job ?

any link to download that document , In which in detail how to write crontab job or do some R & D.

Thanks again.

this will help you in crontab

Thank you ,Yogesh Sawant