Question

I want to run a python program 1000 times. If successful it returns output in about 90 seconds, else continue to run may be for 4 hours. I want to run a bash script that will run the python program in a loop in such a way that it waits 100 seconds for the script to terminate successfully else kill it.

It must not kill the next instance of the program which may become successful.

I am working in Ubuntu 12.04 lts.

for i in {1..1000..1}
do
    ./myprocess.py
    sleep 100
done

#And then what........?

Please help

Était-ce utile?

La solution

Try timeout command. Your situation is the exact case, this command is designed for.

timeout 100 ./myprocess.py
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top