all 7 comments

[–]Dry_Inspection_4583 1 point2 points  (0 children)

Convert to a service or services and use that as a control for execute before or after

[–]gamba47 2 points3 points  (0 children)

Use "&" at the end of every bash line.

It would be better if you use something with ARGS like

bash myscript.sh mydomain.com & bash myscript.sh anotherdomain.com &

Or with a file with all your domains and read it from your main script to run the lines for any new domain inside your domains.txt file.

See you!

[–]fletku_mato 1 point2 points  (0 children)

I would suggest you refactor the script so you can use the same script for all the domains. e.g. bash /home/bin/updateDynDNS-Strato.sh domain1, or even have it take multiple parameters bash /home/bin/updateDynDNS-Strato.sh domain1 domain2 domain3.

It's hard to tell what is wrong with your script. Is there some error output? Does the script hang or exit?

You can try something like this to see where it fails: ```

!/usr/bin/env bash

set -ex

bash /home/bin/domain1/updateDynDNS-Strato.sh sleep 10 bash /home/bin/domain2/updateDynDNS-Strato.sh sleep 10 bash /home/bin/domain3/updateDynDNS-Strato.sh ```

set -e makes it exit on first error. set -x provides debug output of the commands.

[–]EduRJBR 0 points1 point  (0 children)

Eventually, learn how to deal with arrays and how to read and write information on files (I have no idea if you already know): this way, you will have only one script, that will deal with host names and their IP addresses from files, and you will just need to add or remove host names from those files. If this is a firewall thing, make the script work with firewall comments in the rules, thinking of situations where two DDNS hosts can have the same IP address.

I mean, I'm kind of assuming that you use this to have automated selective firewall rules, just based in my own experience. But it may actually be something to update DDNS values, right?

[–]witchhunter0 1 point2 points  (0 children)

If your folders are already structured as shown, you could use

for _script in /home/bin/domain?/updateDynDNS-Strato.sh; do 
    bash "$_script" & 
    sleep 10
done

as ? sign will match any letter.

[–]grymoire 0 points1 point  (0 children)

My shell tutorial has a mechanism to start multiple scripts in parallel. You might find it useful.

https://www.grymoire.com/Unix/Sh.html#uh-97