systemd 服务管理

来源:互联网 发布:2016电脑点歌软件 编辑:程序博客网 时间:2024/06/05 13:05

systemd 服务管理

列出所有的服务:

[root@localhost ~]# systemctl list-units --all --type=service   UNIT                                LOAD      ACTIVE   SUB     DESCRIPTION  auditd.service                      loaded    active   running Security Auditing Service  brandbot.service                    loaded    inactive dead    Flexible Branding Service  cpupower.service                    loaded    inactive dead    Configure CPU power related setti  crond.service                       loaded    active   running Command Scheduler  dbus.service                        loaded    active   running D-Bus System Message Bus● display-manager.service             not-found inactive dead    display-manager.service  dm-event.service                    loaded    inactive dead    Device-mapper event daemon  dracut-shutdown.service             loaded    inactive dead    Restore /run/initramfs  ebtables.service                    loaded    inactive dead    Ethernet Bridge Filtering tables  emergency.service                   loaded    inactive dead    Emergency Shell● exim.service                        not-found inactive dead    exim.service  ......LOAD   = Reflects whether the unit definition was properly loaded.ACTIVE = The high-level unit activation state, i.e. generalization of SUB.SUB    = The low-level unit activation state, values depend on unit type.87 loaded units listed.To show all installed unit files use 'systemctl list-unit-files'.

服务开机启动

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

服务开机不启动

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

查看服务状态

[root@localhost ~]# systemctl status crond.service ● crond.service - Command Scheduler   Loaded: loaded (/usr/lib/systemd/system/crond.service; disabled; vendor preset: enabled)   Active: active (running) since 二 2017-12-05 08:33:57 CST; 1h 9min ago Main PID: 690 (crond)   CGroup: /system.slice/crond.service           └─690 /usr/sbin/crond -n1205 08:33:57 localhost.localdomain systemd[1]: Started Command Scheduler.1205 08:33:57 localhost.localdomain systemd[1]: Starting Command Scheduler...1205 08:33:57 localhost.localdomain crond[690]: (CRON) INFO (RANDOM_DELAY will be scaled ....)1205 08:33:57 localhost.localdomain crond[690]: (CRON) INFO (running with inotify support)Hint: Some lines were ellipsized, use -l to show in full.

停止/开启/重启服务

[root@localhost ~]# systemctl stop crond.service[root@localhost ~]# systemctl start crond.service[root@localhost ~]# systemctl restart crond.service

检测服务是否开机启动

[root@localhost ~]# systemctl is-enabled crond.serviceenabled[root@localhost ~]# systemctl disable crond.serviceRemoved symlink /etc/systemd/system/multi-user.target.wants/crond.service.[root@localhost ~]# systemctl is-enabled crond.servicedisabled
原创粉丝点击