在 linux 上的 python 脚本中重新加载 apache
Reload apache within a python script on linux
您好,我正在尝试创建一个 python 文件来重新加载 apache2,该文件的代码是:
import os
os.system("service apache2 reload")
当我在终端中使用命令时,一切正常,但是当我 运行 python 脚本时,我得到了这个错误:
Job for apache2.service failed.
See "systemctl status apache2.service" and "journalctl -xe" for details.
所以我检查了 journalctl
并得到了这个:
nov 29 13:50:19 gerrietech apachectl[37415]: Action 'graceful' failed.
nov 29 13:50:19 gerrietech apachectl[37415]: The Apache error log may have more information.
结束错误日志:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.50.183. Set the 'ServerName' directive globally to suppress this message
[Mon Nov 29 13:37:35.533656 2021] [mpm_prefork:notice] [pid 36741] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:37:35.533672 2021] [core:notice] [pid 36741] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 29 13:38:23.180736 2021] [mpm_prefork:notice] [pid 36741] AH00169: caught SIGTERM, shutting down
[Mon Nov 29 13:38:45.809351 2021] [mpm_prefork:notice] [pid 37219] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:38:45.809422 2021] [core:notice] [pid 37219] AH00094: Command line: '/usr/sbin/apache2'
我该如何解决这个问题?
在我使用 /etc/init.d/apache2 重新加载而不是服务 apache2 重新启动后,我没有收到任何错误并且脚本执行了它应该执行的操作
您好,我正在尝试创建一个 python 文件来重新加载 apache2,该文件的代码是:
import os
os.system("service apache2 reload")
当我在终端中使用命令时,一切正常,但是当我 运行 python 脚本时,我得到了这个错误:
Job for apache2.service failed.
See "systemctl status apache2.service" and "journalctl -xe" for details.
所以我检查了 journalctl
并得到了这个:
nov 29 13:50:19 gerrietech apachectl[37415]: Action 'graceful' failed.
nov 29 13:50:19 gerrietech apachectl[37415]: The Apache error log may have more information.
结束错误日志:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.50.183. Set the 'ServerName' directive globally to suppress this message
[Mon Nov 29 13:37:35.533656 2021] [mpm_prefork:notice] [pid 36741] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:37:35.533672 2021] [core:notice] [pid 36741] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 29 13:38:23.180736 2021] [mpm_prefork:notice] [pid 36741] AH00169: caught SIGTERM, shutting down
[Mon Nov 29 13:38:45.809351 2021] [mpm_prefork:notice] [pid 37219] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:38:45.809422 2021] [core:notice] [pid 37219] AH00094: Command line: '/usr/sbin/apache2'
我该如何解决这个问题?
在我使用 /etc/init.d/apache2 重新加载而不是服务 apache2 重新启动后,我没有收到任何错误并且脚本执行了它应该执行的操作