【问题标题】:Run php shell_exec in background [duplicate]在后台运行 php shell_exec [重复]
【发布时间】:2014-08-24 07:15:52
【问题描述】:

我有一个文件

运行.php

代码如下

<?php

$shell_cmd = '/usr/bin/aria2c --on-bt-download-complete ./hook.sh "http://sometorrent.com/file.torrent"';

shell_exec($shell_cmd .' 2>&1 > out.log');

echo $shell_cmd;
?>

我尝试通过网站运行这个脚本

http://mywebsite.com/run.php

我的浏览器继续加载缓冲,直到种子完成,我如何在后台运行以便它立即在后台执行。

【问题讨论】:

    标签: php


    【解决方案1】:
    <?php
    
    $shell_cmd = '/usr/bin/aria2c --on-bt-download-complete ./hook.sh "http://sometorrent.com/file.torrent"';
    
    shell_exec($shell_cmd .' > out.log &');
    
    echo $shell_cmd;
    ?>
    

    这将在后台运行 shell 命令

    【讨论】:

    • 我尝试了您的解决方案,但我的程序仍在缓冲运行,直到脚本执行完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2013-09-21
    相关资源
    最近更新 更多