I was looking for the best way to find the number of running processes with the same name via the command line in Linux. For example if I wanted to find the number of bash processes running and get "5". Currently I have a script that does a 'pidof ' and then does a count on the tokenized string. This works fine but I was wondering if there was a better way that can be done entirely via the command line. Thanks in advance for your help.
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Stop child process when parent process stops
- Error building gcc 4.8.3 from source: libstdc++.so
- Program doesn’t terminate when using processes
Following bash script can be run as a cron job and you can possibly get email if any process forks itself too much.
Replace 10 with your number of concern.
TODO: "10" could be passed as command line parameter as well. Also, few system processes can be put into exception list.