Welcome on my blog

We use cookies to ensure you get the best experience on our website.

BASH – Script ping few machines at the same time

Autor: chmajster 19.07.2023
#!/bin/bash

# Set array of servers
servers=("server1" "server2" "server3")

# Set timeout
timeout=5

# Function to check ping for a server
check_ping() {
    host=$1
    ping -c 1 -W $timeout $host > /dev/null
    if [ $? -eq 0 ]; then
        echo "$host is responding to ping."
    else
        echo "$host is not responding to ping."
    fi
}

# Iterate over the servers array and check ping
for server in "${servers[@]}"; do
    check_ping "$server"
done
Tagi:
Dodaj komentarz

Search
Categories
O Blogu

Cześć Podróżniku!

Ta strona ma nie być typowym poradnikiem w IT, Głównym jej cel to zapisanie krótkich notatek, które mogą się przydać w codziennym życiu podczas korzystania/konfiguracji różnych urządzeń np. Ustawienia DHCP na Routerze Cisco, Ustawieniu Karty sieciowej na Linuxie itp.

Buy me A coffee
[Empty]

Wszelkie prawa zastrzeżone