0

I have one tool that performs a long-running task. This tool accepts a configuration file. Right now I need to run simultaneously about 15 instances with different configs (using screen for this).

All instances should be restarted at the same time (or almost the same time).

But I think this task can be automated somehow to start/stop all possible configurations.

1 Answers1

2

Of course it can, that's what shellscripts are for. Lets assume your configs are all in /etc/myapp. Then something like this will do the trick:

killall myapp
while pgrep myapp &>/dev/null; do
  sleep 0.1
done
for config in /etc/myapp/*; do
    screen -S mapp.$config /usr/local/bin/myapp --config $config
done

As this is only tangentially related to server administration, I think it's better to ask any followup questions on the unix&linux site.

Hauke Laging
  • 5,285
  • 2
  • 24
  • 40
Dennis Kaarsemaker
  • 19,277
  • 2
  • 44
  • 70