启动一个服务
systemctl start postfix.service
关闭一个服务
systemctl stop postfix.service
重启一个服务
systemctl restart postfix.service
显示一个服务的状态
systemctl status postfix.service
在开机时启用一个服务
systemctl enable postfix.service
在开机时禁用一个服务
systemctl disable postfix.service
查看服务是否开机启动
systemctl is-enabled postfix.service;echo $?
查看已启动的服务列表
systemctl list-unit-files|grep enabled
检查你的系统中是否安装有systemd并确定当前安装的版本
# systemctl –version
systemd 215
+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR
上例中很清楚地表明,我们安装了215版本的systemd。
检查systemd和systemctl的二进制文件和库文件的安装位置
# whereis systemd
systemd: /usr/lib/systemd /etc/systemd /usr/share/systemd /usr/share/man/man1/systemd.1.gz
# whereis systemctl
systemctl: /usr/bin/systemctl /usr/share/man/man1/systemctl.1.gz
检查systemd是否运行
# ps -eaf | grep [s]ystemd
root 1 0 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd –switched-root –system –deserialize 23
root 444 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 469 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 555 1 0 16:27 ? 00:00:00 /usr/lib/systemd/systemd-logind
dbus 556 1 0 16:27 ? 00:00:00 /bin/dbus-daemon –system –address=systemd: –nofork –nopidfile –systemd-activation
注意:systemd是作为父进程(PID=1)运行的。在上面带(-e)参数的ps命令输出中,选择所有进程,(-a)选择除会话前导外的所有进程,并使用(-f)参数输出完整格式列表(即 -eaf)。
也请注意上例中后随的方括号和例子中剩余部分。方括号表达式是grep的字符类表达式的一部分。
分析systemd启动进程
# systemd-analyze
Startup finished in 487ms (kernel) + 2.776s (initrd) + 20.229s (userspace) = 23.493s
分析启动时各个进程花费的时间
# systemd-analyze blame
8.565s mariadb.service
7.991s webmin.service
6.095s postfix.service
4.311s httpd.service
3.926s firewalld.service
3.780s kdump.service
3.238s tuned.service
1.712s network.service
1.394s lvm2-monitor.service
1.126s systemd-logind.service
….
分类: UBUNTU

1 条评论

lijun · 2017年8月24日 下午2:22

😛 😛

评论已关闭。