使用 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.
使用 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.
使用 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.