Problem running Jenkins as a system service on Ubuntu

241 views
Skip to first unread message

gianpaolo

unread,
Nov 8, 2019, 7:25:46 AM11/8/19
to Jenkins Users
Hello
I've installed and run Jenkins successfully, but at the first reboot I coudnt get it up again.
I have the journal log:

 systemd[1]: Starting Jenkins - open source automation server...
jenkins[3540]: Correct java version found
jenkins[3540]:  * Starting Jenkins Automation Server jenkins
jenkins[3540]: chown: changing ownership of '/var/run/jenkins':    Operation not permitted
su[3580]: PAM audit_log_acct_message() failed: Operation not permitted
su[3580]: pam_authenticate: System error
jenkins[3540]: su: System error
su[3580]: FAILED su for jenkins by root
su[3580]: - ??? root:jenkins
jenkins[3540]:    ...fail!
ci systemd[1]: jenkins.service: Main process exited, code=exited,   status=7/NOTRUNNING
systemd[1]: jenkins.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Jenkins - open source automation server.

I posted the question also on superuser



Can you help me?

Thanks
Gianpaolo

ravi krishna

unread,
Nov 8, 2019, 7:47:39 AM11/8/19
to jenkins...@googlegroups.com
Hello Gianaolo,

Hope you logged in with root user or Jenkins user must have sudo permissions. 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5f886501-5849-45d5-873e-650c5102ce9b%40googlegroups.com.


--

gianpaolo

unread,
Nov 8, 2019, 8:34:50 AM11/8/19
to Jenkins Users
Hi
it's a nightmare. I've tried all the possible solutions and reinstalled everything.

Is there a complete ubuntu instruction?
i have followed this:

Still, after the first reboot, I'm again not able to get it running.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.

gianpaolo

unread,
Nov 8, 2019, 9:03:28 AM11/8/19
to Jenkins Users
ok
the only thing that I miss now is why at every reboot I have to run

sudo service jenkins start

the service is enabled, why does it need to be manually run every time?

Dirk Heinrichs

unread,
Nov 8, 2019, 9:25:36 AM11/8/19
to jenkins...@googlegroups.com
Am Freitag, den 08.11.2019, 01:46 -0800 schrieb gianpaolo:

jenkins[3540]: chown: changing ownership of '/var/run/jenkins':    Operation not permitted
su[3580]: PAM audit_log_acct_message() failed: Operation not permitted
su[3580]: pam_authenticate: System error
jenkins[3540]: su: System error
su[3580]: FAILED su for jenkins by root
su[3580]: - ??? root:jenkins
jenkins[3540]:    ...fail!

Looks like a problem with your PAM setup. Can you login as root and then "su - jenkins" from the shell?

Bye...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

gianpaolo

unread,
Nov 8, 2019, 9:37:35 AM11/8/19
to Jenkins Users
Hi Dirk
I re-installed everything. It seems a little bit better. Service comes up and comes down immediately.
Related to pam session as you suggested?

ov 08 15:32:35 ci systemd[1]: Started Jenkins - open source automation server.
Nov 08 15:32:36 ci jenkins[2637]: Correct java version found
Nov 08 15:32:36 ci jenkins[2637]:  * Starting Jenkins Automation Server jenkins
Nov 08 15:32:36 ci su[2678]: Successful su for jenkins by root
Nov 08 15:32:36 ci su[2678]: + ??? root:jenkins
Nov 08 15:32:36 ci su[2678]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Nov 08 15:32:36 ci su[2678]: pam_unix(su:session): session closed for user jenkins
Nov 08 15:32:37 ci jenkins[2637]:    ...done.
Nov 08 15:32:37 ci jenkins[2711]: Correct java version found
Nov 08 15:32:37 ci jenkins[2711]:  * Stopping Jenkins Automation Server jenkins
Nov 08 15:32:38 ci jenkins[2711]:    ...done.
root@ci:~# su - jenkins
jenkins@ci:~$ 

gianpaolo

unread,
Nov 8, 2019, 9:53:55 AM11/8/19
to Jenkins Users
YES!

In case someone runs into the same issue, here the jenkins.service that solved my problem

[Unit]
Description=Jenkins - open source automation server

[Service]
ExecStart=/etc/init.d/jenkins start
ExecStop=/etc/init.d/jenkins stop
GuessMainPID=no
IgnoreSIGPIPE=no
KillMode=process
LimitNOFILE=64000
LimitNPROC=64000
ProtectHome=true
ProtectSystem=full
RemainAfterExit=yes
TimeoutSec=5min
Type=oneshot

[Install]
WantedBy=multi-user.target

KillExcludeUsers=root jenkins



based on this post


The issue seems to be that systemd kills the user processes when starting jenkins with systemctl.
I wrote a jenkins .service file and added the Jenkins user to KillExcludeUsers in /etc/systemd/logind.conf; https://gist.github.com/konstruktoid/1bc96c4f5030f37bd5f5142cc2718b35


What a nightmare. Never had so much issue installing something on unix.
I'm just a developer but fortunately I love unix enough to not give up ^__^

Ciao!

Dirk Heinrichs

unread,
Nov 8, 2019, 10:01:28 AM11/8/19
to jenkins...@googlegroups.com
Am Freitag, den 08.11.2019, 06:53 -0800 schrieb gianpaolo:

The issue seems to be that systemd kills the user processes when starting jenkins with systemctl.
I wrote a jenkins .service file and added the Jenkins user to KillExcludeUsers in /etc/systemd/logind.conf; https://gist.github.com/konstruktoid/1bc96c4f5030f37bd5f5142cc2718b35

Strange. I am running Jenkins on several Debian and Ubuntu machines and have never seen such behaviour.

BTW: You should not modify the service file provided by the package. It's better to create an overlay file (/etc/systemd/system/jenkins.service.d/local.conf) which contains your modifications to avoid having them removed when the package is updated.

gianpaolo

unread,
Nov 8, 2019, 10:21:46 AM11/8/19
to Jenkins Users


On Friday, November 8, 2019 at 4:01:28 PM UTC+1, Dirk Heinrichs wrote:
Am Freitag, den 08.11.2019, 06:53 -0800 schrieb gianpaolo:

The issue seems to be that systemd kills the user processes when starting jenkins with systemctl.
I wrote a jenkins .service file and added the Jenkins user to KillExcludeUsers in /etc/systemd/logind.conf; https://gist.github.com/konstruktoid/1bc96c4f5030f37bd5f5142cc2718b35

Strange. I am running Jenkins on several Debian and Ubuntu machines and have never seen such behaviour.

BTW: You should not modify the service file provided by the package. It's better to create an overlay file (/etc/systemd/system/jenkins.service.d/local.conf) which contains your modifications to avoid having them removed when the package is updated.

Bye...

 
Thank you very much! I didn't know about the overlay file.

Reply all
Reply to author
Forward
0 new messages