1

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?

4

1 に答える 1

3

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.

于 2012-09-18T22:31:12.670 に答える