0

According to the CLI help of ElasticSearch, you can start ElasticSearch in the background with elasticsearch -d or elasticsearch --daemonize. This is what I use all the time locally, as it seems to take much less ressources and doesn't need to keep your terminal open.

But how can you stop the daemon with the CLI?

bolino
  • 273
  • 3
  • 12

1 Answers1

2

You would tell it to shut it down by sending the appropriate signal (SIGTERM) to the process.

Note that normally you wouldn't be doing this manually, rather making use of whatever service management facilities are provided by your OS.

To simplify the process of knowing the process id, you can pass the -p argument to have it create a pid file when starting.

eg

./bin/elasticsearch -p elasticsearch-pid -d

which creates the file elasticsearch-pid, which you can then use when shutting it down, like so:

kill -SIGTERM `cat elasticsearch-pid`

Also see the Stopping Elasticsearch section of the documentation.

Håkan Lindqvist
  • 33,741
  • 5
  • 65
  • 90
  • Thanks, very clear. Side question while I'm at it - though I know it would be more appropriate on SuperUser: does MacOS system provide any way with the graphical interface to also stop the running daemon(s)? Would the ElasticSearch daemon launched in CLI appear in MacOS Activity Monitor? – bolino Dec 01 '20 at 03:40
  • After trying, it seems the ElasticSearch daemon launched in CLI doesn't appear in MacOS Activity Monitor. I wonder why. – bolino Dec 01 '20 at 03:45