Changed _run_cmd to retry if a cmd fails.