Search code examples
linuxbashgnome

Using bash script to kill a process running in another terminal and closing the terminal


so, i have a bash script that opens a terminal and runs a java jar which keeps running until you kill it, i have another script that kills this process but the problem is that the terminal the jar was running in does not close, anyone can help me? i use linux and gnome.

this are my scripts:

runRobot:
java -cp ~/robot-automation-0.0.1-SNAPSHOT.jar abm.robot_automation.CoordinatorV2

openTerminalAndRun:
gnome-terminal -e "bash -c ~/src/main/resources/runRobot.sh;bash"

killRobot:
pkill -f CoordinatorV2


Solution

  • Just add an exit to the end of the openTerminalAndRun script instead of the trailing bash command:

    gnome-terminal -e "bash -c ~/src/main/resources/runRobot.sh;exit"