Shell_exec php with nohup

前端 未结 3 647
借酒劲吻你
借酒劲吻你 2021-01-17 18:21

I think there are tons of similar posts but I haven\'t yet found a solution after searching around.

Basically, I\'m trying to run two scripts in the background. When

相关标签:
3条回答
  • 2021-01-17 18:45

    Try:

    $output = shell_exec('/usr/bin/nohup php script.php >/dev/null 2>&1 &');
    

    Or:

    exec('/usr/bin/nohup php script.php >/dev/null 2>&1 &');
    
    0 讨论(0)
  • 2021-01-17 18:46
    <?php
    function execInBackground($cmd) {
        if (substr(php_uname(), 0, 7) == "Windows"){
            pclose(popen("start /B ". $cmd, "r")); 
        }
        else {
            exec($cmd . " > /dev/null &");  
        }
    }
    
    // take note: to get your PHP_PATH, try looking at your phpinfo :)
    echo execInBackground("/usr/local/php53/bin/php 'example2.php'");
    ?>
    
    0 讨论(0)
  • 2021-01-17 19:04

    This shoul work:

    shell_exec('nohup /usr/bin/php path/to/script.php > output.txt &');
    
    0 讨论(0)
提交回复
热议问题