12

I am running into an issue where a fresh install of Jenkins is not accessible. This is the error and OS details: Upon starting jenkins results in "OK" status message however if I run status-all | grep jenkins it results in:

jenkins dead but pid file exists

Running on Red Hat Enterprise Linux Server release 6.2 (Santiago) with Yum as package manager.

rpm -qa | grep java

java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64
tzdata-java-2011l-4.el6.noarch
libvirt-java-0.4.7-1.el6.noarch
libvirt-java-devel-0.4.7-1.el6.noarch
java-1.6.0-openjdk-devel-1.6.0.0-1.61.1.11.11.el6_4.x86_64

Permissions are:

ls -la /var/lib/jenkins/
total 8
drwxr-xr-x   2 jenkins jenkins 4096 Aug 27 00:21 .
drwxr-xr-x. 29 root    root    4096 Aug 27 14:47 ..

Has anyone resolved this before?

3ck
  • 539
  • 1
  • 4
  • 13
  • Have a look at the log file and see what errors you're getting there. – Brad Peabody Aug 27 '13 at 22:42
  • How about catalina.out - that one empty too? Mine has all kinds of stuff in it. There's also a conf/logging.properties that you can use to adjust the log verbosity. – Brad Peabody Aug 28 '13 at 03:34
  • No tomcat on this box. - Installed by this documentation: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions – 3ck Aug 28 '13 at 17:30
  • @user3811048 I also have the same issue but bit difference. When Jenkins stopped GitLab is can access via browser and when GitLab is stopped Jenkins can access via browser, but can't access both at the same time even Jenkins running at 8080 port and GitLab running at 80 port. – Chaminda Bandara Oct 27 '18 at 15:14

17 Answers17

12

Change JENKINS_AJP_PORT="8009" (OR whatever value) to JENKINS_AJP_PORT="-1"

It will work for sure.

Sufian
  • 6,405
  • 16
  • 66
  • 120
lokesh1607
  • 136
  • 1
  • 3
  • 1
    I've no words to thank you! My Jenkins broke immediately after I installed Tomcat and I tried all kinds of fixes with no effect whatsoever until this! Thank you, thank you, thank you! – Stan Apr 10 '15 at 17:30
  • @user3811048 -- I run the above command it successfully executed. but when i check the status again I am getting the same message `jenkins dead but pid file exists` – Varun Sep 16 '15 at 06:30
  • 6
    Why does this change work and what are the implications of making this change? There is nothing listening on 8009, but making this change does get Jenkins to restart. – Hazok Jul 06 '16 at 23:27
  • 1
    @user3811048 Where is that config file please ? – Chaminda Bandara Oct 27 '18 at 14:37
10

While following AWS tutorial on Set up a build pipeline with Jenkins and Amazon ECS I encountered the exact same error.

Changing ports did not solve the problem.

I figured out that the error was coming from the version of Java installed along Jenkins.

Updated java-1.7.0-openjdk to java-1.8.0-openjdk did the trick

EDIT: From Anatoly comment, to update java:

sudo yum install java-1.8.0-openjdk

and then remove old version:

sudo yum remove java-1.7.0-openjdk.x86_64

Finally, restart jenkins service

sudo service jenkins restart
SivolcC
  • 3,258
  • 2
  • 14
  • 32
  • 2
    wow perfect, thank you. To update java: install `sudo yum install java-1.8.0-openjdk` and then remove old version `sudo yum remove java-1.7.0-openjdk.x86_64` – Anatoly Vasilyev Jun 20 '17 at 09:59
  • yep that help me =) I think amazon should fix the tutorial by now. – pelos Nov 10 '17 at 08:39
2

Usually the tomcat service is taking over the 8080 port. Try to stop the tomcat service and rerun the jenkins service.

service tomcat stop;

service jenkins start

Worked for me.

1

I was getting the same error, I could not restart the instance in any way.

I did a "yum update" in the server and that fixed the problem.

  • java version "1.7.0_55"
  • Jenkins ver. 1.571
Miguel Reyes
  • 2,444
  • 1
  • 21
  • 11
  • Wow, I tried many of the other solutions listed above this, and just updating it worked. I'm guessing some java library dependency was out of date after I updated to Java 8. – The Unknown Dev Sep 28 '17 at 18:38
1

Just experienced this problem with RHEL install. The fix for me was to explicitly set the JENKINS_JAVA_CMD configuration parameter.

E.g.

sudo vim /etc/sysconfig/jenkins
update:
    JENKINS_JAVA_CMD=""
to:
    JENKINS_JAVA_CMD="/usr/java/default/bin/java"
  • Based on the comment in that config file, it says it will use a "suitable" java when its left blank. I guess this should only work if you have multiple java installations and it is using the wrong one. – The Unknown Dev Sep 28 '17 at 18:16
0

Just a hunch - RHEL/CentOS have file execution disabled on the /tmp directory by default.

Try:

mount -o remount,exec /tmp

And then (re)start Jenkins.

That enables binaries to be executed (also .so files to be loaded) from the /tmp/ directory, which it looks like this particular packaging of Jenkins requires in order to load some kind of JNI code. When I tried installing and running on CentOS 6.4 this was the only issue I had.

If that works, then you can either set it so this happens by default at startup using the settings in /etc/fstab (workable but lowers security on your system), or try to hack the startup process of the install you've got (not recommended), or install it using Tomcat or other packaging that doesn't require file execution on the /tmp directory (recommended but more work).

Brad Peabody
  • 10,917
  • 9
  • 44
  • 63
  • `mount: can't find /tmp in /etc/fstab or /etc/mtab` - I'm getting this error. – coding_idiot Jan 29 '14 at 09:01
  • 1
    Note for the next person who wants to down vote this answer: The error "jenkins dead but pid file exists" means just that - you started jenkins and it died and only the pid file remains. That error message is not enough data to conclude _why_ it died. My answer here was based on a hunch. Just because your Jenkins doesn't work and you don't know why, doesn't mean you should down vote my answer ;) I find it amusing that the post below that says "It will work for sure" is just as likely to not work - for the same reasons above. – Brad Peabody Apr 04 '15 at 08:45
  • 1
    Please please please down vote this answer - especially if you have no idea how to administer a Linux machine or what is wrong with yours. – Brad Peabody Nov 17 '15 at 22:25
  • 1
    @coding_idot - just answering for posterity - this error means there is no /tmp directory in the normal mount listing at /etc/fstab - you are probably running a different type of Linux. (Original post talks about RHEL, which is why my answer is specific to that.) – Brad Peabody Nov 17 '15 at 22:30
0

Please do changes in following steps(Assuming - you want to set port 8888 as jenkins port )

1. You have to edit /etc/init.d/jenkins.

Add the following two lines at the top of the file after DAEMON_ARGS:

HTTP_PORT=8888 JENKINS_ARGS="--httpPort=$HTTP_PORT"

2.Edit the /etc/sysconfig/jenkins

and change

JENKINS_PORT="8888"

Start Jenkins service with the following command from terminal

service jenkins start

Check Jenkins' status

service jenkins status
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
0

From the logs my issue was java.io.FileNotFoundException: /var/cache/jenkins/war/META-INF/MANIFEST.MF (Permission denied)

Which swithced ownership from my user Jenkins runs as to "jenkins", chown'ing fixed the problem

IanWatson
  • 1,649
  • 2
  • 27
  • 49
0

The following helped me:

some time there will be stale some jenkins processes, so ps -ef | grep jenkins kill all of them and restart as above it will be clean.

ps -ef | grep jenkins
sudo kill -kill <pid>

Taken from here (thanks to @sharp)

Community
  • 1
  • 1
ItayB
  • 10,377
  • 9
  • 50
  • 77
0
cd /etc/sysconfig/jenkins

Change JENKINS_AJP_PORT

Change it from

JENKINS_AJP_PORT="8009"

to

JENKINS_AJP_PORT="-1"
HadeS
  • 2,020
  • 19
  • 36
  • Why does this change work and what are the implications of making this change? There is nothing listening on 8009, but making this change does get Jenkins to restart. – Hazok Jul 06 '16 at 23:26
0

for the above error i managed to go to /var/run/jenkins.pid and removed an already existing processing ID.

Then jenkins process was started and its running successfully now.

0

Ensure that the owner of the jenkins.log file is the jenkins user

chown jenkins:jenkins jenkins.log

Without correct ownership, jenkins will crash as soon as you start the service

Sayse
  • 42,633
  • 14
  • 77
  • 146
0

Try to change the user from jenkins to root in /etc/sysconfig/jenkins

JENKINS_USER="root"

OR

check the ownership of /var/lib/jenkins /var/cache/jenkins

Change the ownership to jenkins and change the user in /etc/sysconfig/jenkins to "jenkins" it will work. Also change the ownership of /var/logs/jenkins

Chetan kapoor
  • 821
  • 12
  • 14
0

The error I had was actually due to the fact that /var/run/jenkins was owned by root rather than the jenkins user. The following fixed the issue for me:

sudo chown -R jenkins:jenkins /var/run/jenkins
Yevgeniy Brikman
  • 8,711
  • 6
  • 46
  • 60
0

In the following file:

/etc/sysconfig/jenkins

I had to set the following value:

JENKINS_USER="root"
Jonathan
  • 6,507
  • 5
  • 37
  • 47
SRao
  • 1
  • 3
0

This also results when your machine upgrade Java and Jenkins installed earlier with older version of Java. Change Java path in jenkins.xml.

-1
sudo vim /etc/sysconfig/jenkins
     update:
       JENKINS_USER="jenkins"
        to:


    JENKINS_USER="root"

work for me

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Vivi
  • 1
  • Please edit with more information. Code-only and "try this" answers are discouraged, because they contain no searchable content, and don't explain why someone should "try this". We make an effort here to be a resource for knowledge. – abarisone Jul 06 '16 at 05:36