We are trying to run a script to stop elasticsearch.
When I execute ps aux |grep elastic
I am getting:
root@baldelas01:/tmp# ps aux |grep elastic
root 3016819 0.0 0.1 8248 4164 pts/2 S 14:43 0:00 su elasticsearch
elastic+ 3016820 0.0 0.1 7460 4260 pts/2 S+ 14:43 0:00 bash
elastic+ 3016870 0.8 33.9 5562772 1369948 pts/2 Sl 14:43 0:37 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-3054796781310172182 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/opt/elasticsearch-6.6.1 -Des.path.conf=/opt/elasticsearch-6.6.1/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /opt/elasticsearch-6.6.1/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
elastic+ 3016887 0.0 0.1 121920 6900 pts/2 Sl 14:43 0:00 /opt/elasticsearch-6.6.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root 3019325 0.0 0.0 6432 736 pts/1 R+ 15:54 0:00 grep --color=auto elastic
root@baldelas01:/tmp#
How do I get the PID : 3016870 in the script and execute kill -9?
I tried pidof
but that does not give any result.
sudo service elasticsearch stop
? See also https://www.elastic.co/guide/en/elasticsearch/reference/6.5/stopping-elasticsearch.html They have a specific section on how to stop elasticsearch and why you should use specific commands. Killing should be the last resort ;) They also include a version using a pid :) – Rinzwind Mar 29 '21 at 11:16