bash script stops execution in while loop - why?

与世无争的帅哥 提交于 2019-12-02 07:24:26

From the comments we got that there actually are input files you are looping over (of what kind soever) and that ffmpeg at least starts once. Then, you are stuck.

Add

&> ffmpeg.outerr < /dev/null 

to your ffmpeg command and monitor the file ffmpeg.outerr while your "loop", i.e. ffmpeg, executes. It will tell you what the problem is. Either you can solve this problem yourself, or you come back to stackoverflow with this ffmpeg-specific problem using the tag ffmpeg.

try this in terminal

create bash nohup.sh and paste in this

#!/bin/sh
while true
do
 /var/www/bash/Someother-bash-script-goes-here.sh
 sleep 60
done

in terminal type where nohup.sh is located

nohup sh nohup.sh >/dev/null 2>&1 &

nohup, will execute every 60 seconds, you can grep service check like this

 #!/bin/sh
SERVICE='ffmpeg'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, will not bother ffmpeg yet"
else
    echo "$SERVICE is not running"
    echo "$SERVICE is not running!" | /var/www/bash/start_service.sh
fi

The answer is to add '-nostdin' to ffmpeg (wouldn't answer to an old question like this, but still tops on related Google searches).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!