문제

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

도움이 되었습니까?

해결책

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

timeout 100 ./myprocess.py
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top