“Systemctl”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
 
第7行: 第7行:
 
systemctl list-unit-files
 
systemctl list-unit-files
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
  
 
=== status ===
 
=== status ===

2023年1月24日 (二) 16:09的最新版本

Query or send control commands to the systemd manager.

查询或发送控制命令到系统(后台服务)管理器

查看开机自启动服务

systemctl list-unit-files


status

Show runtime status of one or more units

显示一个或多个单元的运行状态

[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com
[root@localhost ~]#


start

Start (activate) one or more units

启动(激活)一个或多个单位

[root@localhost ~]# systemctl start docker.service
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-08-17 05:03:39 CST; 8s ago
     Docs: https://docs.docker.com
 Main PID: 2097 (dockerd)
    Tasks: 45
   Memory: 151.4M
   CGroup: /system.slice/docker.service
           ├─2097 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─2288 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2183 -container-ip 172.20.0.2 -container-port 2181
           ├─2294 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 2183 -container-ip 172.20.0.2 -container-port 2181
           ├─2304 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2181 -container-ip 172.20.0.3 -container-port 2181
           ├─2310 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 2181 -container-ip 172.20.0.3 -container-port 2181
           ├─2322 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2182 -container-ip 172.20.0.4 -container-port 2181
           └─2327 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 2182 -container-ip 172.20.0.4 -container-port 2181

Aug 17 05:03:33 localhost dockerd[2097]: time="2022-08-17T05:03:33.559559666+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}" module=grpc
Aug 17 05:03:33 localhost dockerd[2097]: time="2022-08-17T05:03:33.559565367+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Aug 17 05:03:33 localhost dockerd[2097]: time="2022-08-17T05:03:33.573102663+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Aug 17 05:03:33 localhost dockerd[2097]: time="2022-08-17T05:03:33.845547050+08:00" level=info msg="Loading containers: start."
Aug 17 05:03:34 localhost dockerd[2097]: time="2022-08-17T05:03:34.576992258+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Aug 17 05:03:39 bogon dockerd[2097]: time="2022-08-17T05:03:39.242556129+08:00" level=info msg="Loading containers: done."
Aug 17 05:03:39 bogon dockerd[2097]: time="2022-08-17T05:03:39.351245831+08:00" level=info msg="Docker daemon" commit=a89b842 graphdriver(s)=overlay2 version=20.10.17
Aug 17 05:03:39 bogon dockerd[2097]: time="2022-08-17T05:03:39.351377939+08:00" level=info msg="Daemon has completed initialization"
Aug 17 05:03:39 bogon systemd[1]: Started Docker Application Container Engine.
Aug 17 05:03:39 bogon dockerd[2097]: time="2022-08-17T05:03:39.466942476+08:00" level=info msg="API listen on /var/run/docker.sock"
[root@localhost ~]#


enable

启用后台服务开机自启动

[root@zk0 ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@zk0 ~]#

disable

禁用后台服务开机自启动

[root@localhost ~]# systemctl disable docker.service
Removed symlink /etc/systemd/system/multi-user.target.wants/docker.service.
[root@localhost ~]#