我希望能够关闭我的CentOS 7机器,按下电源按钮。由于它无法发挥作用,所以我尝试了以下几种方法:
yum -y install acpid
service acpid start
chkconfig acpid on不幸的是,没有效果,可能是因为这只适用于CentOS 6.x。有人知道如何通过按下电源按钮来启用关机吗?
发布于 2015-11-20 18:04:04
我也有这个问题。
本质上,您将在日志中看到什么(如果systemd配置正确,上面的任何一种方法都有效--systemd为您翻译旧的“service”命令.(至少在CentOS7中)
Nov 20 11:12:06 localhost systemd-logind: Power key pressed.
Nov 20 11:12:06 localhost systemd: SELinux policy denies access因此,您需要浏览到/var/log/audit.log,然后您将看到如下所示:
init_t:s0 msg='avc: denied { start } for auid=-1 uid=0 gid=0 path="/usr/lib/systemd/system/poweroff.target" scontext=system_u:system_r:apmd_t:s0 tcontext=system_u:object_r:power_unit_file_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'好的,为什么系统配置文件不再在/etc中了?不管怎样,我digress....something关于/usr/lib/systemd/system/poweroff.target是关闭的?:顺便说一句,我真的很喜欢新的自动文件现在是如何混淆自己的.现在没有真正的方向可走..。这个文件完全没用。这些选择中的任何一个意味着什么?我猜有些PFY管理员的工作安全.再给我加时赛。(一定是另一个“特征”!)
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Power-Off
Documentation=man:systemd.special(7)
DefaultDependencies=no
Requires=systemd-poweroff.service
After=systemd-poweroff.service
AllowIsolate=yes
[Install]
Alias=ctrl-alt-del.target好的,在这一点上,我们有足够的信息来寻找答案。问题是一个阻止系统关闭系统的SELinux策略。
看哪!有一个bug针对它:https://bugzilla.redhat.com/show_bug.cgi?id=1224211
从本质上讲,在评论#60左右,他们发现存在一个策略错误。它将通过定期更新来修复,但我只想安装“everything”中的软件包。所以,看来我必须等到CentOS发布7.2才能解决这个问题!
发布于 2014-10-25 09:34:23
RHEL 7和Centos 7已经实现了从systemd (SysV)启动脚本和运行级到systemd的转换。因此,激活acpid的命令应该是:
systemctl start acpid
systemctl enable acpidhttps://unix.stackexchange.com/questions/159316
复制相似问题