shell - Stop WebSphere JVM within time limit? -


i wondering if can stop single jvm within specific time limit. if not stopping within time limit kill process shell script.

if executing ./stopserver.sh jvm_name - run till jvm not stopped or till error , exit.

what trying :./stopserver.sh jvm_name - if not stopped within 2 min(suppose), kill process (but how figure out not stopped within 2 mins through shell script before process go killing). can write condition kill . not sure how checks if jvm stopped within 2 mins or not can go ahead kill process.

can please suggest shell script code identify if jvm stopped within specific time limit or not?

a jvm process , such can stopped kill command - kill $processid or more brutal kill -9 $processid

if start jvm script using java ... suggest putting & @ end of line , in following line

processid=$! 

which saves id of background process. then

sleep 120 

will wait 2 min. have 2 options - either kill

kill $processid /dev/null 2>&1 

or first check if processid might (very unlikely) reused process (or use other way check if jvm has finished, maybe file indicates java program) , if matches use kill.

ps -ef|grep -w $processid |grep -w java > /dev/null 

if has returncode 0 continue kill

test $? -eq 0 && kill $processid 

i trust processid either jvm or not used @ all


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo