Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8160565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:16:52+00:00 2026-06-06T18:16:52+00:00

Consider the following script: for host in $(get-all-hosts) do (restart-server $host; wait-for-server-to-come-up $host) &

  • 0

Consider the following script:

for host in $(get-all-hosts)
do
  (restart-server $host; wait-for-server-to-come-up $host) &
done

As you might guess, restart-server restarts the server and the command wait-for-server-to-come-up blocks until the server is up (e.g., grep -m 1 'server up' <(tail -f /path/to/log)).

This script essentially restarts all servers simultaneously. I’m curious what’s the simplest way to modify this script to stop after some fixed number of servers, and wait for one server to come up before proceeding with the next restart so that a maximum of, say, 4 servers is down at any given time. One way I know of doing this is to simply restart in chunks of 4 and wait on all of the pids in each chunk, but I’m hoping it’s not that hard to do something smarter.

Some scratch work toward a solution:

Second try, using some ideas from Dennis’s link. Almost ideal for a vanilla Bash solution:

mkfifo mfifo
exec 3<>mfifo
echo >&3
echo >&3
echo >&3
for host in $(get-all-hosts)
do
  read
  (restart-server $host; wait-for-server-to-come-up $host; echo >&3) &
done <&3

My biggest remaining complaint with this solution is that it assumes there isn’t already a named queue called mfifo that’s already in use. Other than that, I haven’t seen any problems, and it works exactly as expected as far as I can tell.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:16:53+00:00Added an answer on June 6, 2026 at 6:16 pm

    xargs has a parallelism feature similar to parallel:

    echo $(get-all-hosts) | tr ' ' '\n' | xargs -P 4 -n 1 ./blocking-restart
    

    ..where blocking-restart is expected to take the name of a single server, restart it and wait until it’s finished. Note the tr puts each host on its own line, which is what xargs expects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following script: println ls -l.execute().text Why do I get the following error
Consider following script (it's total nonsense in pseudo-language): if (Request.hostMatch(asfasfasf.com) && someString.existsIn(new String[] {brr,
Consider following script: SET LANGUAGE 'German' GO SET DATEFIRST 1 GO DECLARE @FullDate DATETIME
Consider following make: all: a b a: echo a exit 1 b: echo b
Consider the following script for outputting some XML code: var xmlAsString = '<?xml version=1.0?><person><name
Consider the following PowerShell script: function Alpha { # write-output 'Uncomment this line and
Consider the following example: <html> <body> <script type=text/javascript> var str=filename.jpg; var pattOne = new
Consider the following document <html> <body> This is some content <script type=text/javascript src=verySlowToRespond.js></script> This
Consider the following html snippet <!DOCTYPE html> <html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.4.2.js ></script> <script
Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.