heh, I needed something just like this a few days ago because Java is an asshole to start in init
Code:
kill -9 $(ps aux | grep "java -jar JTS3ServerMod.jar" | grep -v grep | cut -c10-15)
replace the INSIDE of the quotation marks with command used to start process
But that is only if you have absolutely no way of knowing what the process ID is when you start it
You can modify the start script to do this
Code:
#!/bin/sh
PW_PATH=/PWServer
PID_PATH=$PW_PATH/pids
# >> means append, > means overwrite
cd $PW_PATH/gamed; ./gs is12 >> $PW_PATH/logs/game_all.log &
# $! contains the process ID of the last command run by user using it
echo $! > $PID_PATH/is12.pid
And for the kill script you could then use that pid file to do this
Code:
#!/bin/sh
PID_PATH=/PWServer/pids
kill -9 $(cat is12.pid)
btw using $() is basically an anonymous function in bash, whatever comes out of the stdout in the end is the return value.