How to exit a team in n seconds?

I am writing a script and would like to know how to ask one of the teams to exit in a few seconds. For example, let's assume that my script executes two application commands.

#!/bin/bash for i in 'cat servers' do <command 1> $i >> Output_file #Consistency command <command 2> $i >> Output_file #Communication check done 

These commands are designed to verify consistency & communication with the application. I want to know how I can make sure that the 1 & 2 command runs in just a few seconds, and if there is no response from a specific host, go to the next command.

+9
source share
1 answer

bash The coreutils command has a "timeout" command.

From the manual:

DESCRIPTION

Run COMMAND and kill it if it still works after NUMBER seconds. SUFFIX can be “s” in seconds (default), “m” for minutes, “h” for several hours, or “d” for several days.

eg:

timeout 5 sleep 6

+13
source

Source: https://habr.com/ru/post/945673/


All Articles