Jerry Geis
2007-Apr-07 02:16 UTC
[CentOS] command to ensure other command does last longer than 5 seconds
Hi, I am wondering if there exists a centos command that runs another command and ensures the second command doesnt take more than x seconds? When x is given on the command line. If the second command is not "done" the first command will just kill it and both exit. Does such a method or command exist? I just need to ensure the second command does just continue to run and run and run. Thanks, Jerry
Peter Gross
2007-Apr-07 04:06 UTC
[CentOS] command to ensure other command does last longer than 5 seconds
Jerry Geis wrote:> Hi, > > I am wondering if there exists a centos command that runs another command > and ensures the second command doesnt take more than x seconds? When x > is given on the command line. > > If the second command is not "done" the first command will just kill it > and both exit. > > Does such a method or command exist? > > I just need to ensure the second command does just continue to run and > run and run.Here's my admittedly kludgey quick and dirty way of doing this .... write a shell script that does the following: 1. takes two arguments -- the command to run (in quotes) and then the drip dead time (in seconds? or minutes?) 2. start the command in the background, saving its PID in a var (say $pid). 3. create an "at" job to kill the pid at the appointed time, as in: echo kill -TERM $pid | at now + 15 minutes If the job has already finished, the kill -TERM will hopefully be harmless (i.e., the pid's haven't cycled around and there is now a new, but different, job with the same pid).
James Pearson
2007-Apr-07 11:02 UTC
[CentOS] command to ensure other command does last longer than 5 seconds
On 07/04/07, Jerry Geis <geisj at pagestation.com> wrote:> Hi, > > I am wondering if there exists a centos command that runs another command > and ensures the second command doesnt take more than x seconds? When x > is given on the command line. > > If the second command is not "done" the first command will just kill it > and both exit. > > Does such a method or command exist? > > I just need to ensure the second command does just continue to run and > run and run.I found something on the web ages ago that does just this - see: <http://www.splode.com/~friedman/software/scripts/src/with-timeout> James Pearson
Possibly Parallel Threads
- [Bug 2570] New: ssh-keygen -p will convert openssh-format keyfiles back to pem, improperly?
- Slow performance with lots of files in one directory
- Packet Timing and Data Leaks
- Voicemailmain automatic extension detection?
- How to instruct Wine to use MSIE rendering engine by default instead of Gecko?