systemd 服务管理

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 -n

1205 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.service
enabled
[root@localhost ~]# systemctl disable crond.service
Removed symlink /etc/systemd/system/multi-user.target.wants/crond.service.
[root@localhost ~]# systemctl is-enabled crond.service
disabled
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值