Ubuntu 启动/停止 jenkins,和查看 jenkins 状态

本文将介绍和整理关于 jenkins 启动、关闭,以及启用或禁止开机启动的命令。

查看 jenkins 状态

使用 sudo service jenkins status 命令查看 jenkins 状态,示例如下:

hxstrive@localhost:~$ sudo service jenkins status
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-05-03 18:35:31 CST; 1 day 14h ago
   Main PID: 11597 (java)
      Tasks: 48 (limit: 5809)
     Memory: 290.3M
        CPU: 4min 49.517s
     CGroup: /system.slice/jenkins.service
             └─11597 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

5月 03 18:35:17 localhost jenkins[11597]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
5月 03 18:35:17 localhost jenkins[11597]: WARNING: All illegal access operations will be denied in a future release
5月 03 18:35:26 localhost jenkins[11597]: 2023-05-03 10:35:26.482+0000 [id=35]        INFO        h.p.b.g.GlobalTimeOutConfiguration#load: global timeout not set
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.554+0000 [id=32]        INFO        jenkins.InitReactorRunner$1#onAttained: System config loaded
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.624+0000 [id=33]        INFO        jenkins.InitReactorRunner$1#onAttained: System config adapted
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.662+0000 [id=29]        INFO        jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.833+0000 [id=31]        INFO        jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
5月 03 18:35:31 localhost jenkins[11597]: 2023-05-03 10:35:31.304+0000 [id=34]        INFO        jenkins.InitReactorRunner$1#onAttained: Completed initialization
5月 03 18:35:31 localhost jenkins[11597]: 2023-05-03 10:35:31.713+0000 [id=23]        INFO        hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
5月 03 18:35:31 localhost systemd[1]: Started Jenkins Continuous Integration Server.

启动 jenkins 服务

使用 sudo service jenkins start 启动 jenkins 服务,示例如下:

# 启动 jenkins 服务
hxstrive@localhost:~$ sudo service jenkins start
# 查看 jenkins 状态
hxstrive@localhost:~$ sudo service jenkins status
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-05-05 08:54:32 CST; 4s ago
   Main PID: 66523 (java)
      Tasks: 49 (limit: 5809)
     Memory: 465.9M
        CPU: 57.793s
     CGroup: /system.slice/jenkins.service
             └─66523 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

5月 05 08:54:28 localhost jenkins[66523]: WARNING: All illegal access operations will be denied in a future release
5月 05 08:54:30 localhost jenkins[66523]: 2023-05-05 00:54:30.659+0000 [id=34]        INFO        h.p.b.g.GlobalTimeOutConfiguration#load: global timeout not set
5月 05 08:54:31 localhost jenkins[66523]: 2023-05-05 00:54:31.628+0000 [id=36]        INFO        jenkins.InitReactorRunner$1#onAttained: System config loaded
5月 05 08:54:31 localhost jenkins[66523]: 2023-05-05 00:54:31.631+0000 [id=36]        INFO        jenkins.InitReactorRunner$1#onAttained: System config adapted
5月 05 08:54:31 localhost jenkins[66523]: 2023-05-05 00:54:31.634+0000 [id=34]        INFO        jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
5月 05 08:54:31 localhost jenkins[66523]: 2023-05-05 00:54:31.659+0000 [id=33]        INFO        jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
5月 05 08:54:31 localhost jenkins[66523]: 2023-05-05 00:54:31.787+0000 [id=52]        INFO        hudson.util.Retrier#start: Attempt #1 to do the action check updates server
5月 05 08:54:32 localhost jenkins[66523]: 2023-05-05 00:54:32.131+0000 [id=34]        INFO        jenkins.InitReactorRunner$1#onAttained: Completed initialization
5月 05 08:54:32 localhost jenkins[66523]: 2023-05-05 00:54:32.345+0000 [id=23]        INFO        hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
5月 05 08:54:32 localhost systemd[1]: Started Jenkins Continuous Integration Server.

停止 jenkins 服务

使用 sudo service jenkins stop 命令停止 jenkins 服务,示例如下:

# 停止 jenkins 服务
hxstrive@localhost:~$ sudo service jenkins stop
# 查看 jenkins 服务状态
hxstrive@localhost:~$ sudo service jenkins status
○ jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Fri 2023-05-05 08:53:37 CST; 23s ago
    Process: 11597 ExecStart=/usr/bin/jenkins (code=exited, status=143)
   Main PID: 11597 (code=exited, status=143)
     Status: "Jenkins stopped"
        CPU: 4min 51.632s

5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.624+0000 [id=33]        INFO        jenkins.InitReactorRunner$1#onAttained: System config adapted
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.662+0000 [id=29]        INFO        jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
5月 03 18:35:29 localhost jenkins[11597]: 2023-05-03 10:35:29.833+0000 [id=31]        INFO        jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
5月 03 18:35:31 localhost jenkins[11597]: 2023-05-03 10:35:31.304+0000 [id=34]        INFO        jenkins.InitReactorRunner$1#onAttained: Completed initialization
5月 03 18:35:31 localhost jenkins[11597]: 2023-05-03 10:35:31.713+0000 [id=23]        INFO        hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
5月 03 18:35:31 localhost systemd[1]: Started Jenkins Continuous Integration Server.
5月 05 08:53:35 localhost systemd[1]: Stopping Jenkins Continuous Integration Server...
5月 05 08:53:37 localhost systemd[1]: jenkins.service: Deactivated successfully.
5月 05 08:53:37 localhost systemd[1]: Stopped Jenkins Continuous Integration Server.
5月 05 08:53:37 localhost systemd[1]: jenkins.service: Consumed 4min 51.632s CPU time.

启用开机启动

使用 sudo systemctl enable jenkins 命令开启 jenkins 开机自动启动,示例如下:

hxstrive@localhost:~$ sudo systemctl enable jenkins
Synchronizing state of jenkins.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable jenkins
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service.

禁用开机启动

使用 sudo systemctl disable jenkins 命令禁用 jenkins 开机自动启动,示例如下:

hxstrive@localhost:~$ sudo systemctl disable jenkins
Synchronizing state of jenkins.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable jenkins
Removed /etc/systemd/system/multi-user.target.wants/jenkins.service.
谁不会休息,谁就不会工作。 —— 列宁
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站专注于 Java、数据库(MySQL、Oracle)、Linux、软件架构及大数据等多领域技术知识分享。涵盖丰富的原创与精选技术文章,助力技术传播与交流。无论是技术新手渴望入门,还是资深开发者寻求进阶,这里都能为您提供深度见解与实用经验,让复杂编码变得轻松易懂,携手共赴技术提升新高度。如有侵权,请来信告知:hxstrive@outlook.com
其他应用
公众号