Monday, September 5, 2022

[SOLVED] How to get pkill on git bash

Issue

background

years ago I made a Minecraft spigot server and found a bash script to turn it on, in the script, it has a restart function that makes use of pkill to kill the old server and start a new one, I tried using it on my new spigot server to find that bash doesn't contain pkill, any google search I use relating to "how to get pkill on git bash windows 10" doesn't give me anything useful, the script has the following in it, the file is a .sh if that matters:

# /bin/sh
while true
do
java -Xms4G -Xmx6G -jar spigot-1.16.3.jar nogui
pkill -f "spigot" #Not really needed, just there in case of anything.
echo Its off..sleeping for 5
sleep 5
done

My question is, what can I use to kill the process by name like pkill would, or could I somehow install pkill to just work?

any help is appreciated and I apologise in advance if this is a stupid question.


Solution

If the shell is to be executed in a Windows Git bash session, then you do have access to Windows commands, like taskkill, in said bash session.
For example, in my bash session, I can type:

vonc@voncav MINGW64 /d/git/gtarsum (master)
$ taskkill
ERROR: Invalid syntax. Neither /FI nor /PID nor /IM were specified.
Type "TASKKILL /?" for usage.

In your case, a taskkill /F /IM spigot should be enough.



Answered By - VonC
Answer Checked By - Katrina (WPSolving Volunteer)