Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
coreutils timeout and other timeout script i searched, they apply for a CDM but i'd like to apply timeout for a linux script, if not finished for a period. like:
cd XXX && CMD && sleep 3 && kill -0 XX
How to do it?
You can pass the spawning of a subshell to timeout, and have the subshell run the code that needs to be timed out:
#!/bin/bash timeout 5 bash -c "ping google.com -c 2; ping yahoo.com -c 10"
If you clarify what you need exactly there may be cleaner ways to achieve this.
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.