在后台执行shell命令run php


Execute shell command run php in background

我使用以下命令通过shell运行php脚本:

php script.php

如何键入此命令以便在后台运行并将输出记录到文件中?

我试过

php script.php 2>&1 > out.log

但当我合上油灰后,剧本就停止了。

您可以使用nohup(无挂断)

  nohup php script.php 2>&1 > out.log

或者使用cron或at在后台中运行脚本

在命令后面添加一个&

试着这样调用:

php script.php 2>&1 > out.log &