2023년 4월 5일 작성
nohup의 Log를 원하는 형식으로 쌓기
nohup의 표준 출력을 원하는 곳에 원하는 형식으로 쌓을 수 있습니다.
nohup
의 Log
- nohup을 사용하면 기본적으로
nohup.out
에 표준 출력을 쌓습니다.
Code | Name |
---|---|
0 | 표준 입력 |
1 | 표준 출력 |
2 | 표준 오류 |
표준 출력을 원하는 곳에 쌓기
nohup ./my_shellscript.sh > nohup_script.out
- log를 다른 file에 출력할 수 있습니다.
- redirection(
>
,>>
)을 이용합니다.
- redirection(
표준 출력과 표준 오류를 각각 다른 File에 쓰기
nohup ./my_shellscript.sh 1 > my_shellscript.out 2 > my_shellscript.err &
- 표준 출력(1)은 my_shellscript.out file로 redirection합니다.
- 표준 오류(2)는 my_shellscript.err file로 redirection합니다.
표준 출력과 표준 오류를 같은 File에 쓰기
nohup ./my_shellscript.sh > my_shellscript.log 2>&1 &
- 표준 출력(1)을 my_shellscript.log에 씁니다.
- 표준 오류(2)도 표준 출력(1)이 쓰여지는 file에 redirection합니다.
표준 출력(Log)을 기록하고 싶지 않을 때
nohup ./my_shellscript.sh > /dev/null