Bash script stops execution of ffmpeg in while loop - why?

前端 未结 3 545
庸人自扰
庸人自扰 2020-12-11 20:33

I have this bash script for converting .mp4 video to .mp3 audio. It runs, but does the loop only once, though there are more mp4 files in /ho

相关标签:
3条回答
  • 2020-12-11 20:49

    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
    
    0 讨论(0)
  • 2020-12-11 20:57

    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.

    0 讨论(0)
  • 2020-12-11 21:06

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

    0 讨论(0)
提交回复
热议问题