timeout
noun
say it: “TIME-owt” /ˈtaɪmˌaʊt/
A command that runs another command with a time limit and stops it when the time is up, exiting with 124.
What does timeout do?
timeout gives a command a deadline. timeout 3 sleep 10 stops sleep after three seconds, and the exit code 124 says it gave up. A command that finishes in time keeps its own exit code. In a script, it keeps a wait for a server from going on forever.
timeout 3 sleep 10
echo $? # 124: timeout stopped it
In a sentence
- “Exit code 124 means timeout gave up on the command.”
- “timeout 5 stopped the wait after five seconds, so the script said the server never answered.”
Level: Journeyman · More Unix terms at this level
Updated