PHP and shell_exec

前端 未结 6 1115
余生分开走
余生分开走 2021-01-22 14:06

I have a PHP website and I would like to execute a very long Python script in background (300 MB memory and 100 seconds). The process communication is done via database: when th

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 14:54

    Found this before and helped me solve my background execution problem:

    function background_exec($command)
    {
        if(substr(php_uname(), 0, 7) == 'Windows')
        {
            pclose(popen('start "background_exec" ' . $command, 'r'));
        }
        else
        {
            exec($command . ' > /dev/null &');
        }
    }
    

    Source:

    http://www.warpturn.com/execute-a-background-process-on-windows-and-linux-with-php/

提交回复
热议问题