Find and remove orphaned processes on UNIX systems


During the course of system administration, orphaned processes can remain even after you have shut down services. These orphaned processes can maintain holds on ports, files, and system resources. The ps command and kill command are best suited to find and remove the orphaned processes. 

You can use these commands to identify orphaned processes: 

ps -ef | grep <portnum
 
ps -ef | grep <sasusername>
 
Note: Replace the italicized text with the value from your system. These commands must be run while services are down in order to quickly identify orphaned processes. 

Output from these commands looks similar to the following: 

 
sas      26857 26615  0  2018 ?        00:45:55 /opt/SASHome/SASPrivateJavaRuntimeEnvironment/9.4/jre/bin/java -cp /opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/hq-server/bin/tomcat-juli.jar:/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/tomcat-8.0.36.A.RELEASE/bin/bootstrap.jar -Djava.awt.headless=true -XX:MaxPermSize=192m -Xmx2g -Xms1g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -Dserver.home=/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE -Dcatalina.config=file:/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/hq-server/conf/hq-catalina.properties -Dcom.sun.management.jmxremote -Djava.endorsed.dirs=/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/tomcat-8.0.36.A.RELEASE/common/endorsed -Dcatalina.base=/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/hq-server -Dcatalina.home=/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/tomcat-8.0.36.A.RELEASE -Djava.io.tmpdir=/opt/config/Lev1/Web/SASEnvironmentManager/server-5.8.0-EE/hq-engine/hq-server/temp -Djava.util.logging.manager=com.springsource.tcserver.serviceability.logging.
TcServerLogManager -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=java.lang,java.util,org.
apache.activemq,org.
fusesource.hawtbuf,com.thoughtworks.xstream.mapper,org.hyperic.hq -Dorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true org.apache.catalina.startup.Bootstrap start

 

This example shows the SAS® Environment Manager server. The first output is the user, followed by the process ID (PID) of the process listed, and then the PID of the parent process. 

To stop an orphaned process, run the following command: 

 
kill -9 <PID of the orphaned process
 

Note: Replace the italicized text with the value from your system.

This command should eliminate the orphaned process that causes issues.