Everyone who is using Oracle Weblogic must had a thought like “Where the *** is the stop script to kill my nodemanager proces”…. Well, i did. So i wrote a simple stop script which can be better probally, but it does the job.
#!/bin/bash PID=`ps -efw | grep -i "Xms128m" | grep -i nodemanager | awk '{print $2}'` if [ ! -z $PID ]; then echo "Killing nodemanager with PID: $PID" kill $PID CHECK=`ps -e -o pid | grep $PID` if [ -z $CHECK ]; then echo "Nodemanager stop success" fi else echo "No nodemanager process running" fi
Remember to copy this snippet into a bash file and set the correct permissions.
Some developers like to stop nodemanager programmaticly. I.E.
Note: You could use it to stop and start adminservers for example…
You could use following python definitions:
# RETURN LIST OF PROCESS IDS FROM GREPING PROCESS COMMANDS def psgrep(str): pat = re.compile(str) cmd = "ps -e -o pid,command" lines = shlines("ps -e -o pid,command") pids = [] for line in lines: cols = string.split(line) if cols[1] == "grep": continue for col in cols[1:]: if pat.search(col): pids.append(cols[0]) continue return pids def stop_process_tree(ppid): time.sleep(1) pids = get_child_processes(ppid) while len(pids) > 0: for pid in pids: stop_process_tree(pid) pids = get_child_processes(ppid) kill_process(ppid) return def kill_process(pid): if pid == None or pid == '': return time.sleep(1) if shout("ps -o pid= --pid " + pid) != '': os.system("kill " + pid) for i in range(30): time.sleep(1) if shout("ps -o pid= --pid " + pid) == '': return os.system("kill -9 " + pid) for i in range(30): time.sleep(1) if shout("ps -o pid= --pid " + pid) == '': return error("Cannot kill " + pid) return def get_child_processes(ppid): return string.split(shout("ps -o pid= --ppid " + ppid))
Advertisements