You are probably looking for the timeout
command in coreutils. Since it’s a part of coreutils, it is technically a C solution, but it’s still coreutils. info timeout
for more details.
Here’s an example:
timeout 5 /path/to/slow/command with options
More Related Contents:
- How do I parse command line arguments in Bash?
- How do I set a variable to the output of a command in Bash?
- Why do you need ./ (dot-slash) before executable or script name to run it in bash?
- How to iterate over arguments in a Bash script
- What is the purpose of “&&” in a shell command?
- Capture stdout and stderr into different variables
- Remove the last line from a file in Bash
- How to get Maven project version to the bash command line
- How to replace ${} placeholders in a text file?
- Longest line in a file
- How to run some command before or after every Bash command entered from console?
- How to use arguments from previous command?
- How can I get a recursive full-path listing, one line per file?
- How to reload .bash_profile from the command line
- Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?
- What is your single most favorite command-line trick using Bash? [closed]
- Execute a shell function with timeout
- Convert line endings [duplicate]
- Multiplication on command line terminal
- -bash: !”: event not found [closed]
- Retry a Bash command with timeout
- Why doesn’t my terminal output unicode characters properly?
- How can I check if a program exists from a Bash script?
- What is indirect expansion? What does ${!var*} mean?
- How to apply shell command to each line of a command output?
- How to split strings over multiple lines in Bash?
- Creating a string variable name from the value of another string
- Sorting strings with numbers in Bash [duplicate]
- How to break out of a loop in Bash?
- Access arguments to Bash script inside a function [duplicate]