httpd -k restart:打印一些像" service httpd restart"

时间:2017-07-10 18:13:55

标签: apache service httpd.conf

通过服务命令重新启动apache:

service httpd restart

Stopping httpd: [ OK ] 
Starting httpd: [ OK ] 

我希望能够在不使用"服务"的情况下获得相同的输出。命令。

以下命令有效,但不会打印任何内容。

/usr/sbin/httpd -k restart

1 个答案:

答案 0 :(得分:0)

“service”命令运行/etc/init.d/httpd脚本,此脚本重新启动httpd并打印信息。

使用/usr/sbin/httpd -k restart,您正在重新启动httpd而不打印任何内容。

  

我希望能够在不使用“service”命令的情况下获得相同的输出。

选项1

运行httpd init脚本:

/etc/init.d/httpd restart

选项2

您可以创建如下的脚本:

#!/bin/bash
echo "Restarting httpd..."
/usr/sbin/httpd -k restart

例如,将其命名为“restart_httpd.sh”并将其设为可执行文件:

chmod +x restart_httpd.sh

运行它:

./restart_httpd.sh
相关问题