download1002
2012-02-23 02:43
浏览 55
已采纳

从PHP运行命令,退出脚本,但保持命令运行

I am running a PHP script that uses the passthru function to run system commands in the background. By redirecting the output and putting the & at the end of the command, the script is able to continue executing without waiting for the system command to finish. However, the PHP script itself does not exit until all commands are complete. Is there a way that the PHP script can start a system command and then not have to wait for that command to finish before exiting?

图片转代码服务由CSDN问答提供 功能建议

我正在运行一个PHP脚本,它使用 passthru 函数来运行系统命令。 背景。 通过重定向输出并将& 放在命令的末尾,脚本可以继续执行而无需等待系统命令完成。 但是,在完成所有命令之前,PHP脚本本身不会退出。 有没有办法让PHP脚本可以启动系统命令,然后在退出之前不必等待该命令完成?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpd66100 2012-02-23 03:23
    已采纳

    Have you tried using nohup?

    Instead of

    my_command >/dev/null &
    

    do

    nohup mycommand >/dev/null &
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题