加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer

发布时间:2021-07-06 04:17:08 所属栏目:大数据 来源: https://www.jb51.cc
导读:当我执行以下无效时(使用ps aux | grep mplayer检查,其中1.wav是一个10分钟的音频文件): system("mplayer /tmp/1.wav"); // Failedsystem("sudo -u myusername mplayer /tmp/1.wav"); // Failedsystem("mplayer /tmp/1.wav "); // Failedsystem("(mplayer /

当我执行以下无效时(使用ps aux | grep mplayer检查,其中1.wav是一个10分钟的音频文件):

system("mplayer /tmp/1.wav"); // Failed
system("sudo -u myusername mplayer /tmp/1.wav"); // Failed
system("mplayer /tmp/1.wav &"); // Failed
system("(mplayer /tmp/demo.wav) >/dev/null &"); //Failed according to: http://www.PHP.net/manual/fr/function.system.PHP#88543
system("sudo -u myusername -i mplayer /tmp/demo.wav");

如何使用PHP运行后台进程?只有这个工作,但它像批处理文件,我在同一个系统. $PHP -r“system(‘mplayer /tmp/demo.wav’);”;

谢谢

注意:
1)错误:

Cannot find HOME directory.
Home directory /var/www not ours.
AO: [pulse] Init Failed: Connection refused
Failed to initialize audio driver 'pulse'
Home directory /var/www not ours.
waitpid(): No child processes
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Internal error

[AO_ALSA] Playback open error: Connection refused
Failed to initialize audio driver 'alsa'
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
Home directory /var/www not ours.
waitpid(): No child processes
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Internal error

[AO_ALSA] Playback open error: Connection refused
Home directory /var/www not ours.
AO: [pulse] Init Failed: Connection refused
Home directory /var/www not ours.
waitpid(): No child processes
Home directory /var/www not ours.
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Aborting. $HOME not set!

2)& 5)错误:

sudo: sorry, you must have a tty to run sudo

3)错误:

Cannot find HOME directory.
File not found: '/tmp/1.wav'
Failed to open /tmp/1.wav.

4)错误:

Cannot find HOME directory.
Home directory /var/www not ours.
AO: [pulse] Init Failed: Connection refused
Failed to initialize audio driver 'pulse'
Home directory /var/www not ours.
waitpid(): No child processes
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Internal error

[AO_ALSA] Playback open error: Connection refused
Failed to initialize audio driver 'alsa'
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
Home directory /var/www not ours.
waitpid(): No child processes
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Internal error

[AO_ALSA] Playback open error: Connection refused
Home directory /var/www not ours.
waitpid(): No child processes
AO: [pulse] Init Failed: Internal error
Home directory /var/www not ours.
waitpid(): No child processes
Home directory /var/www not ours.
waitpid(): No child processes
[AO_ALSA] alsa-lib: pulse.c:229:(pulse_connect) PulseAudio: Unable to connect: Internal error

Aborting. $HOME not set!

解决方法:

显然,没有简单的方法可以这样做:system()函数或back-quotes表示法都不允许你运行后台任务……有人在PHP doc website上发布了一个(非常繁琐)的解决方案.

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读