I'm working with Amazon's DynamoDB and I can't figure out how to programmatically kill the process reliably by name or PID.
I need to restart it since I'm holding all data in memory and I can delete the entire thing by just easily restarting the process. Problem is I can't figure out how to kill it as easily as starting it.
ps -ax | grep "Dynamo"
returns 19355 ttys001 0:28.31 /usr/bin/java -Djava.library.path=./DynamoDBLocal_lib -jar /Users/user/workspace/lib/DynamoDBLocal.jar -sharedDb -port 8000 -inMemory
But when I try killall DynamoDBLocal.jar
I receive No matching processes belonging to you were found
and the PID changes every time it's started up.
How can I programmatically find the PID to send to kill -9 PID
or properly killall
by name?
EDIT: Finished! Here's my work to share with others:
alias start_dynamo='java -Djava.library.path=./DynamoDBLocal_lib -jar /Users/user/workspace/lib/DynamoDBLocal.jar -sharedDb -port 8000 -inMemory &'
alias end_dynamo="kill `ps -ax | grep Dynamo | grep -v grep | awk '{print $1}'`"
alias restart_dynamo='end_dynamo; start_dynamo'
Best Answer
should do it. note, this will kill any proc that matches Dynamo