假设shell脚本test.sh
#!/bin/bash
arg=$1
log=/var/www/lighttpd/1.txt
echo $arg >> $log
/usr/local/ffmpeg/bin/ffmpeg -y -i /var/www/lighttpd/1.mp4 /var/www/lighttpd/2.mp4 2>>$log //此命令大约5秒
假设php脚本
<?php
$arg="aaaaa"; //为了传参测试。
shell_exec(" /var/www/lighttpd/test.sh $arg > /dev/null 2>&1 &"); //可以异步执行
echo "test php";
?>
nginx,php服务启起来。
执行 curl "http://10.80.3.17:8090/test.php",即可看见php很快返回,ffmpeg也会完成转码。