Stopping N number of nodes of a Cassandra cluster running on a single machine using bash script

cassandra

I have set up a Multi-Node cassandra (3.11) cluster (with N nodes) in a single Ubuntu machine. I have written a bash script which

  • Creates N copies of conf folder
  • Configures the cassandra yaml file according to the need of N nodes (Such as separating the data and log directories)
  • Creates N copies of cassandra script inside the bin folder

It works correctly so far. But I am a little stuck after that.

I want to stop all the nodes effectively at the end of the script. Any help will be really appreciated at this point.

Thanks in advance!

Best Answer

I figured it out:

kill $(ps auwx | grep '[c]assandra' | awk '{print $2}')