gpt4 book ai didi

apache - Fork shell 脚本(不是 &)

转载 作者:行者123 更新时间:2023-12-04 16:18:01 26 4
gpt4 key购买 nike

我正在通过 PHP 访问网络服务器。我想更新 Apache 配置中的一些信息,所以我启动了一个 shell 脚本来进行更改。然后我想停止并重新启动Apache。

问题:一旦我停止 Apache,我的进程就会停止并且我的 shell 脚本(作为子进程)被杀死。 Apache 从不重启。 Apache 重新启动时也会发生这种情况。

有没有办法为 shell 脚本创建一个独立的非子进程,以便我可以重新启动 Apache?

谢谢,
乙先生

最佳答案

您可以使用 disown :

disown [-ar] [-h] [jobspec ...]

Without options, each jobspec is removed from the table of active jobs. If the `-h' option is given, the job is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If jobspec is not present, and neither the `-a' nor `-r' option is supplied, the current job is used. If no jobspec is supplied, the `-a' option means to remove or mark all jobs; the `-r' option without a jobspec argument restricts operation to running jobs.


./myscript.sh &
disown
./myscript.sh即使启动它的脚本死亡,它也会继续运行。

关于apache - Fork shell 脚本(不是 &),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4817013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com