How do i perform a search of ubuntu operating system processes?
-
We mostly use something like the following to look for active process.
ps -ef | grep apache
Another way of doing searching of active processes is using the
pgrep
command.Using the following process as an example.
redis 1288 1 0 03:04 ? 00:00:03 /usr/bin/redis-server
Search for redis as the command. Returns single process id.
$ pgrep redis 1456
-l option
Search for redis as the command and list it. You can see the actual command is not redis but redis-server.
$ pgrep -l redis 1456 redis-server
-x option
Be more specific search and only search for redis as the command. There is no command called redis so nothing is listed.
$ pgrep -lx redis
However if you search for redis-server, it will exactly match that command.
$ pgrep -lx redis-server 1456 redis-server
-f option
Search for the string redis anywhere in the process list. It finds redis in more than one process
$ pgrep -fl redis 777 runsv 807 svlogd 1185 runsv 1227 svlogd 1288 redis-server
-a option
Sometimes listing the entire command line is more useful.
$ pgrep -fla redis 777 runsv redis_lb 807 svlogd -tt /var/log/opscode/redis_lb 1185 runsv redis 1227 /opt/chef-manage/embedded/bin/svlogd -tt /var/log/chef-manage/redis 1288 /usr/bin/redis-server 10.50.25.15:6379
© Lightnetics 2024