Get the latest tech news

TIL: timeout in Bash scripts


How to use the `timeout` command to terminate processes after a specified time and how to combine it with `until` for smarter shell scripting.

The other day at work we had a Bash script that would set up a web server and wait for it to be up before proceeding to the next things. The script worked fine and we had no issues, until we had an infinite loop. timeout expects a killable command and until is a shell keyword: you can’t SIGTERMuntil.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Bash

Bash

Photo of Timeout

Timeout

Photo of TIL

TIL

Related news:

News photo

Brush (Bo(u)rn(e) RUsty SHell) a POSIX and Bash-Compatible Shell in Rust

News photo

Advanced Shell Scripting with Bash (2006) [pdf]

News photo

Show HN: Prompting LLMs in Bash scripts