Shell_exec 没有 nohup.out
Shell_exec nohup with nohup.out
执行这段代码:
shell_exec('nohup command&');
或这个
shell_exec('nohup command > /path/to/nohup.out 2>&1&');
但是这两种情况都没有nohup.out。我如何通过 php 运行 与 nohup.out nohup?
shell_exec('nohup command > /path/to/nohup.out 2>&1&');
这条线可以。只需确保您对输出文件夹具有写权限。考虑您的输出文件夹是 /usr/nohup-out
ls -l /usr/nohup-out
它应该有写入、读取和执行权限(rwx)。如果没有,请执行此操作:
sudo chmod -R 777 /usr/nohup-out
现在,尝试执行 php 文件。它应该在 /usr/nohup-out
文件夹中创建一个 nohup 文件。
示例脚本和结果:
1. date.php:
<?php
shell_exec('nohup date > /usr/nohup-out/nohup.out 2>&1&');
?>
2。从终端执行 php:
php date.php
3。 nohup.out执行后的内容
Thu Apr 23 11:30:28 IST 2015
执行这段代码:
shell_exec('nohup command&');
或这个
shell_exec('nohup command > /path/to/nohup.out 2>&1&');
但是这两种情况都没有nohup.out。我如何通过 php 运行 与 nohup.out nohup?
shell_exec('nohup command > /path/to/nohup.out 2>&1&');
这条线可以。只需确保您对输出文件夹具有写权限。考虑您的输出文件夹是 /usr/nohup-out
ls -l /usr/nohup-out
它应该有写入、读取和执行权限(rwx)。如果没有,请执行此操作:
sudo chmod -R 777 /usr/nohup-out
现在,尝试执行 php 文件。它应该在 /usr/nohup-out
文件夹中创建一个 nohup 文件。
示例脚本和结果:
1. date.php:
<?php
shell_exec('nohup date > /usr/nohup-out/nohup.out 2>&1&');
?>
2。从终端执行 php:
php date.php
3。 nohup.out执行后的内容
Thu Apr 23 11:30:28 IST 2015