How to get PID and Port # for Jenkins process

I need to get PID and Port # to start the Jenkins process. If I get this PID, I can kill this process if necessary.

I start the Jenkins process with the following commands:

java -jar jenkins.war 

Sometimes the Jenkins process does not start if this port is taken, and the following happens:

 Jenkins home directory: /Users/MacPro/.jenkins found at: $user.home/.jenkins Feb 27, 2016 10:46:09 AM org.eclipse.jetty.util.log.JavaUtilLog warn WARNING: FAILED SelectChannelConnector@0.0.0.0 :8080:java.net.BindException: Address already in use java.net.BindException: Address already in use 

And I know how to start the jenkins process against a specific port #.

You need to know the commands that use the PID and port, the current job.

+7
java jenkins
source share
4 answers

The command will be lower:

 ps -ef| grep jenkins 

The process ID is displayed.

+4
source share

Answer your question 1) In the Unix field, using the command will be ps -ef | grep jenkins , it will display the process id (pid) 2) kill -9 (pid)

+4
source share

That should do the job. Better to find and kill using the same command, saves time:

 ps -Af | grep "jenkins" | grep -v grep | awk '{print$2}' | xargs kill -9 

You can check the process before killing

  ps -Af | grep "jenkins" | grep -v grep | awk '{print$2}' 

If you are using Jenkins with tomcat

 ps -Af | grep "tomcat" | grep -v grep | awk '{print$2}' | xargs kill -9 

Please note that these commands are tested on RHEL.

+3
source share

You can try the following command for cleaner output:

 lsof -Pni | grep mysql 
0
source share

All Articles