php execute a background process

前端 未结 19 1449
萌比男神i
萌比男神i 2020-11-21 07:04

I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware

19条回答
  •  独厮守ぢ
    2020-11-21 07:21

    Write the process as a server-side script in whatever language (php/bash/perl/etc) is handy and then call it from the process control functions in your php script.

    The function probably detects if standard io is used as the output stream and if it is then that will set the return value..if not then it ends

    proc_close( proc_open( "./command --foo=1 &", array(), $foo ) );
    

    I tested this quickly from the command line using "sleep 25s" as the command and it worked like a charm.

    (Answer found here)

提交回复
热议问题