Last active
December 30, 2015 10:55
-
-
Save Viroide/22cf5006925cadabc461 to your computer and use it in GitHub Desktop.
Kills older java process that are in the server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| killOldersJava(){ | |
| javaProcessNumer=`ps -ej | grep java | wc -l` | |
| while [ $javaProcessNumer -gt 1 ] | |
| do | |
| PID=`ps -ej --sort=start_time | grep java | head -n1 | awk '{ print $1 }'` | |
| echo "More than one java process, killing the older PID=$PID" | |
| kill -9 $PID | |
| javaProcessNumer=`ps -ej | grep java | wc -l` | |
| done | |
| PID=`ps -ej --sort=start_time | grep java | head -n1 | awk '{ print $1 }'` | |
| echo "Only one java process PID=$PID , nothing to kill" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment