Pgrep not showing desired output

I am searching for a process that should be up and running. Im using the following command

ps -ef | grep elasticsearch

to get

elastic+  1673     1  0 Jan29 ?        05:08:56 /bin/java -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/share/elasticsearch -cp /usr/share/elasticsearch/lib/elasticsearch-2.3.3.jar:/usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch start -Des.pidfile=/var/run/elasticsearch/elasticsearch.pid -Des.default.path.home=/usr/share/elasticsearch -Des.default.path.logs=/var/log/elasticsearch -Des.default.path.data=/var/lib/elasticsearch -Des.default.path.conf=/etc/elasticsearch

Even the process can be seen using

[root@csdp-e2e-mongodb-secondary-2 init.d]# systemctl status elasticsearch
 elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2017-01-29 01:18:08 GMT; 2 months 3 days ago
     Docs: http://www.elastic.co
  Process: 1660 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 1673 (java)
   CGroup: /system.slice/elasticsearch.service
           1673 /bin/java -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+He...

Jan 29 01:19:43 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:43,206][INFO ][node                     ] [ib_blackwidow] starting ...
Jan 29 01:19:45 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:45,745][INFO ][transport                ] [ib_blackwidow] publish_address {172.29.219.107:9300....107:9300}
Jan 29 01:19:45 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:45,761][INFO ][discovery                ] [ib_blackwidow] installedBase_E2E/eZhgJ6_bTI2uhzhLg_ARpA
Jan 29 01:19:49 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:49,736][INFO ][cluster.service          ] [ib_blackwidow] detected_master {ib_daredevil}{9Nw2CytOTOKECKC...
Jan 29 01:19:51 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:51,369][INFO ][http                     ] [ib_blackwidow] publish_address {172.29.219.107:9200....107:9200}
Jan 29 01:19:51 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:19:51,370][INFO ][node                     ] [ib_blackwidow] started
Jan 29 01:20:15 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:20:15,137][WARN ][monitor.jvm              ] [ib_blackwidow] [gc][young][23][2] duration [8.4s], collection...
Jan 29 01:20:59 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-01-29 01:20:59,531][WARN ][monitor.jvm              ] [ib_blackwidow] [gc][young][64][3] duration [2.4s], collection...
Feb 09 17:11:57 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-02-09 17:11:57,656][INFO ][monitor.jvm              ] [ib_blackwidow] [gc][young][1007321][179] duration [855ms], co...
Mar 27 13:19:02 csdp-e2e-mongodb-secondary-2 elasticsearch[1673]: [2017-03-27 13:19:01,954][INFO ][monitor.jvm              ] [ib_blackwidow] [gc][young][4967003][849] duration [718ms], co...
Hint: Some lines were ellipsized, use -l to show in full.

But I want to check the process status using the pgrep command but it does not return anything.

[root@csdp-e2e-mongodb-secondary-2 init.d]# pgrep -a elasticsearch
[root@csdp-e2e-mongodb-secondary-2 init.d]# 

is there any limitation to pgrep command ?

man pgrep :

1 Like