[명령] timeout 시간제한 명령어

markyang92·2021년 7월 5일
0

linux (ubuntu/debian)

목록 보기
16/37

timeout command

  • timeout 커맨드를 사용하면, 지정 시간동안만 cmd 를 사용하게 한다.
$ timeout 10s bash -c "CMD"


timeout [TIME]
TIME:
's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.
  • 위 형태로, bash 를 이용해 커맨드를 실행 시키므로, 이는 child shell로 실행된다.

return code

timeout 1s bash -c "ssh user@123.456.789.1 \"du -sh ${DIR}\""
echo $?
--> timeout 발생 시: 124
--> timeout 내 성공 시: 0
profile
pllpokko@alumni.kaist.ac.kr

0개의 댓글