I need to execute a command with timeout so it's killed after X time.

I have done tests and it only works when typed in the terminal directly, when in a bash script it seems to not handle the user input like it's not "receiving it"

  • What is the script? what input does the script accept? – Valentin Bajrami Oct 21 '17 at 11:42
  • @val0x00ff I solved it, should I delete this question? – Freedo Oct 21 '17 at 11:51
  • 2
    You can post your own answer and accept is as solved. It could help others who have the same problem. – Valentin Bajrami Oct 21 '17 at 11:53

I found a solution looking at the man page. You need to use timeout --foreground 120s to have your command accept user input when executed in a bash script.

| improve this answer | |
  • Which man page helped you ? – X Tian Oct 21 '17 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.