pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.
#pgrep processname will returns process id for that processname.
root@server-82:~# pgrep apache
19823
22774
22843
22902
22918
22949
22982
22994
23291
23351
23382
root@server-82:~#
#counting number of running processes using pgrep
root@server-82:~# pgrep apache | wc -l
11
root@server-82:~#
#counting number of processes under username root
root@server-82:~# pgrep -u root apache | wc -l
1
root@server-82:~#
Here root is username and apache is process.
#counting number of processes under username www-data for user root
root@server-82:~# pgrep -u www-data apache | wc -l
10
root@server-82:~#
#pgrep processname will returns process id for that processname.
root@server-82:~# pgrep apache
19823
22774
22843
22902
22918
22949
22982
22994
23291
23351
23382
root@server-82:~#
#counting number of running processes using pgrep
root@server-82:~# pgrep apache | wc -l
11
root@server-82:~#
#counting number of processes under username root
root@server-82:~# pgrep -u root apache | wc -l
1
root@server-82:~#
Here root is username and apache is process.
#counting number of processes under username www-data for user root
root@server-82:~# pgrep -u www-data apache | wc -l
10
root@server-82:~#
No comments :
Post a Comment