Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jan 2009 21:46:32 +0100
From:      Sebastian Mellmann <>
To:        Nerius Landys <>
Subject:   Re: shell scripting, how to auto-timeout?
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

> The java process has the potential to run forever, and I want it to
> run for at most 1 second then get killed.  I could write a parent
> script that somehow gets the PID of the child script, but the problem
> is that the java program writes to standard out, the result of the
> program is written to standard out.  I also don't really want to share
> a PID with a temporary file.
> So what I might do is this:
> /usr/local/bin/java PipeGenerator $* &
> sleep 1
> <kill the java command if not already killed>

What about using 'pidof' and then check if it gives you a PID and kill
the process?

> Also with the above code I would be waiting for 1 second even if the
> java process finished sooner.  But that is a penalty I'm willing to
> pay, unless there is a more elegant solution.
> How do I do this?


Want to link to this message? Use this URL: <>