#!/usr/bin/env bash # Stop the demo application. # # Do NOT match on the main class name with `pkill -f`. Any shell whose command line # happens to contain that string -- including the one that wrote this script -- matches # too, and gets killed. Match on the executable being java AND the jar name instead. for p in $(ps -eo pid=,comm=,args= | awk '$2 == "java" && /startup-diagnosis-1\.0\.0\.jar/ { print $1 }'); do kill -9 "$p" 2>/dev/null || true done sleep 1