如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer /tmp/audio.wav”)但没有工作
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer /tmp/audio.wav”)但没有工作,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2863字,纯文字阅读大概需要5分钟。
内容图文
![如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer /tmp/audio.wav”)但没有工作](/upload/InfoBanner/zyjiaocheng/965/7241de695c2c4c9093f8d22c98918ae2.jpg)
当我执行以下无效时(使用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上发布了一个(非常繁琐)的解决方案.
内容总结
以上是互联网集市为您收集整理的如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer /tmp/audio.wav”)但没有工作全部内容,希望文章能够帮你解决如何使用PHP运行Linux后台进程?试过系统(“sudo -u me mplayer /tmp/audio.wav”)但没有工作所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。