Check /proc/${PID} instead of ps. Sleep for 30s