你确定该脚本不包含任何错误吗?这通常是使"
执行很快就会终止
".
首先,追加。
error_reporting(E_ALL); ini_set('display_errors', 1);
在你的脚本顶部显示任何可能存在的错误,然后你可以使用:
nohup php filename.php &
nohup运行一个命令,即使会话被断开或用户
nohup php filename.php >/dev/null 2>&1 &
与上述相同,但不创建
nohup.out
文件。
你也可以使用。
ignore_user_abort(1);
设置客户端断开连接是否应中止脚本的执行
`set_time_limit(0);`
限制了脚本的最大执行时间,在这种情况下,它将运行到
进程结束或apache进程重新启动。
替换代码5】和
filename.php
的路径可以作为一个
全路径
, instead of
php
and
filename.php
, you can use
/usr/bin/php
and
/full/path/to/filename.php
.
建议使用完整路径
以避免
file not found
errors.