Kill process after a given time bash?

There’s a GNU coreutils utility called timeout: http://www.gnu.org/s/coreutils/manual/html_node/timeout-invocation.html If you have it on your platform, you could do: timeout 5 CONNECT_TO_DB if [ $? -eq 124 ]; then # Timeout occurred else # No hang fi

How to kill process inside container? Docker top command

When I reproduce your situation I see different PIDs between docker top <container> and docker exec -it <container> ps -aux. When you do docker exec the command is executed inside the container => should use container’s pid. Otherwise you could do the kill without docker straight from the host, in your case: sudo kill -9 … Read more