即使强制终止,RHEL7上的httpd服务也会自动重新启动

时间:2018-07-25 07:49:52

标签: linux apache systemd rhel7 systemctl

每次我停止httpd服务时,它都会自动出现。下面是配置文件。

[root@server ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

当我停止服务“ systemctl stop httpd”时,我在audit.log中看到以下行。

type=SERVICE_STOP msg=audit(1532445336.059:18928): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

几秒钟后,我立即在日志文件中看到以下条目,表明服务启动命令已执行。

type=SERVICE_START msg=audit(1532445411.613:18931): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=httpd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

好像systemd正在自动启动服务,但是在配置文件中看不到“ Restart = always”。

我什至尝试了以下方法,没有帮助。

[Service]
Restart=on-failure

1 个答案:

答案 0 :(得分:0)

查看systemctl show httpd的完整配置。

其他可能正在启动您的httpd服务器,例如套接字激活或systemd计时器。

如果您不想让任何服务启动,则可以在停止服务后使用systemctl mask httpd,但要谨慎使用-引导时也不会启动。 unmask服务以再次开始使用它。