This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| add_a_timeout [2025/06/02 22:40] – created ken | add_a_timeout [2026/07/07 23:13] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| < | < | ||
| until curl --silent --fail-with-body 10.0.0.1: | until curl --silent --fail-with-body 10.0.0.1: | ||
| - | sleep 1 | + | |
| done | done | ||
| </ | </ | ||
| Line 13: | Line 13: | ||
| This works fine. Unless our web server crashes during startup and we sleep 1 forever.\\ | This works fine. Unless our web server crashes during startup and we sleep 1 forever.\\ | ||
| \\ | \\ | ||
| - | Here comes a handy utility: timeout. As the name suggests, this command adds a timeout to other commands.\\ | + | Here comes a handy utility: timeout. |
| + | As the name suggests, this command adds a timeout to other commands.\\ | ||
| You specify the time limit you want to wait for a command and if that time passes, timeout sends a signal to terminate it and exits with non-zero.\\ | You specify the time limit you want to wait for a command and if that time passes, timeout sends a signal to terminate it and exits with non-zero.\\ | ||
| By default, timeout sends SIGTERM, but you can change it with the --signal flag, e.g. '' | By default, timeout sends SIGTERM, but you can change it with the --signal flag, e.g. '' | ||
| Line 32: | Line 33: | ||
| < | < | ||
| timeout 1m until curl --silent --fail-with-body 10.0.0.1: | timeout 1m until curl --silent --fail-with-body 10.0.0.1: | ||
| - | sleep 1 | + | |
| done | done | ||
| </ | </ | ||
| Line 41: | Line 42: | ||
| < | < | ||
| timeout 1m bash -c "until curl --silent --fail-with-body 10.0.0.1: | timeout 1m bash -c "until curl --silent --fail-with-body 10.0.0.1: | ||
| - | sleep 1 | + | |
| done" | done" | ||
| </ | </ | ||