Artificial intelligent assistant

Uniquely identifying java processes with same name I have two java processes which run using the same file name, `MyApp.jar` (for example). /usr/java/latest/bin/java -jar MyApp.jar These jars exist in different places and use different configurations. I want to be able to kill one process, but don't know how to distinguish between the two. I execute: ps aux | grep [M]yApp.jar And get: admin 21509 0.8 0.1 1199908 20484 ? Sl 08:21 0:00 /usr/java/latest/bin/java -jar MyApp.jar admin 21585 6.7 0.1 1199764 20084 ? Sl 08:21 0:00 I've thought of creating the process with some dummy parameter to be able to distinguish them: /usr/java/latest/bin/java -jar MyApp.jar MyAppTheFirst and /usr/java/latest/bin/java -jar MyApp.jar MyAppTheSecond But this seems a bit wrong to me. Is there a better way?

First, why do you want to kill any of them? If a process is using too many resources you can just get the PID in `top`:


top -n 1


If they need to be restarted on a periodic basis or to react to outside stimuli, use process management:


while true
do
java -jar MyApp.jar &
my_app_pid=$!
while ! whatever_makes_me_think_my_app_should_be_restarted
do
sleep 60
done
kill $my_app_pid
done

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 85d7a23cb50de67e2714200473dbfdbb