K
K
Konstantin2017-09-15 23:05:05
bash
Konstantin, 2017-09-15 23:05:05

How to adapt a bash script to restart many similar programs?

Hello!
There is a sh-script with the following content:

#!/bin/sh
until ffmpeg -i rtsp://............................  blablabla.mp4 ; do
        echo "restarting ffmpeg command..."
        sleep 2
done

As you can see from the content, he stupidly picks up ffmpeg after an unexpected crash. I honestly looked at the script and adapted it to my needs.
The problem is that I will have 30-40 such ffmpeg processes and rivet 30-40 sh-scripts of the same type, even as a person far from programming, this idea seems a little strange to me.
Hence the question for the connoisseurs: how can I "multiply" the script for many similar ffmpeg processes?
Thanks in advance for your time :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2017-09-15
@NGNeer

You need a script with parameters.

#!/bin/sh
until ffmpeg -i rtsp://$1 ; do
        echo "restarting ffmpeg command..."
        sleep 2
done

save it and run it like this
instead of blablabla.mp4 you substitute the address and it is inserted in the script in place of $1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question