Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
And this does stop his processes how? :-) –  Hauke Laging May 9 '13 at 13:28
    
The killall will do that ;) (added after you comment, thanks) –  Dennis Kaarsemaker May 9 '13 at 13:29
    
any thoughts on killall versus pkill? –  glenn jackman May 9 '13 at 13:54
    
what about place all application under same screen session inside different windows ? –  user173090 May 13 '13 at 11:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.