I’m writing a script and at some point I call to “command1” which
does not stop until it CTRL+C is invoked.
- Is there a way to state a timeout for a command? Like:
command1 arguments -timeout 10 - How do I write a CTRL+C command in textual form?
Thx!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
timeoutcommand from GNU coreutils (you may need to install it first, but it comes in most, if not all, Linux distributions):For instance:
will terminate the script after 5 seconds of execution. If you want to send a KILL signal (instead of TERM), use
-kflag.Here you have the full description of the
timeoutcommand.