Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PID and Port # for a Jenkins Process

Tags:

java

jenkins

I need to get PID & Port# for a Jenkins process run. If i get that PID, i can kill the process if ever i need to.

I am running the Jenkins process by below commands:

java -jar jenkins.war 

Sometimes, Jenkins Process fail to start if that port is taken and below occurs:

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 
[email protected]:8080:java.net.BindException: 
Address already in use
java.net.BindException: Address already in use

And I know how to run the jenkins process against a specific Port#.

Need to know the commands for which PID and the port, current job is using.

like image 452
Saikat Avatar asked Feb 27 '16 15:02

Saikat


3 Answers

The command will be below:

ps -ef| grep jenkins 

It will display the process id.

like image 196
Saikat Avatar answered Oct 19 '22 03:10

Saikat


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

like image 27
Praveen Kumar K S Avatar answered Oct 19 '22 04:10

Praveen Kumar K S


This 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 running Jenkins using tomcat

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

Please note that these commands tested on RHEL.

like image 4
Pinaki Mukherjee Avatar answered Oct 19 '22 04:10

Pinaki Mukherjee