Skip to content
Advertisement

Multiple bash commands in background

I am trying to execute multiple single line commands in the background from php exec(). My script watermarks the video and deletes the original video and rename the watermarked video to the original name. I want to run the whole code in the background. I have tried both round () and curly {} braces but failed in the end below is my code which I am trying to run in background.

(/usr/bin/ffmpeg -i video.mp4 -i watermark.png -filter_complex 'overlay=10:10' video_watermarked.mp4 && rm -rf video.mp4 && mv video_watermarked.mp4 video.mp4) & 

Advertisement

Answer

ffmpeg will automatically suspend if it doesn’t have access to standard out.

You have two choices:
nohup /usr/bin/ffmpeg ... Will take care of the redirect for you, and place the output of ffmpeg in a file called nohup.out

Or add 2>&1>/dev/null after the closing bracket in your argument to exec(). This will send both standard out and standard err to /dev/null.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement