어떤 명령어의 결과를 표준출력과 파일 저장을 같이 하고 싶을 때, 사용하는 명령어의 결과를 로깅파일로 만들 때, 유용하다.
실행결과를 표준출력과 파일로 저장
$ echo 'this is tee command' | tee tee.log
this is tee command
$ cat tee.log
this is tee command
실행결과를 표준출력과 파일로 저장. ( -a 옵션을 사용하여 append(추가하기))
$ echo 'this is tee command1' | tee -a tee.log
this is tee command1
$ echo 'this is tee command2' | tee -a tee.log
this is tee command2
$ cat tee.log
this is tee command1
this is tee command2
활용) 일단위 날짜형식의 로깅파일로 만들기
#/bin/bash
echo 'this is tee command1' | tee -a `date +%y%m%d`.log
echo 'this is tee command2' | tee -a `date +%y%m%d`.log
--------------------------------------------------------
$ ./df.sh
this is tee command1
this is tee command2
$ cat 191125.log
this is tee command1
this is tee command2
'Linux > RedHat, CentOS, ubuntu' 카테고리의 다른 글
apache httpd.conf 문법 검사 명령어 (0) | 2021.03.26 |
---|---|
[CentOS] timezone 변경하기 (0) | 2020.03.24 |
CentOS7 mariadb port 변경 (0) | 2020.01.31 |
[ CentOS ] python3로 변경 후 YUM 실행시 SyntaxError: invalid syntax 원인과 해결 방법 (0) | 2019.12.20 |
CentOS 7 SFTP만 사용할 수 있는 계정 만들기 (0) | 2019.11.24 |
[ Centos 5 ~ 6 ] chkconfig를 이용하여 서비스 자동실행 등록 (0) | 2019.11.22 |
centos semanage 명령어 활성화 (0) | 2019.11.22 |
CentOS 7 원격로그 서버 (rsyslog) 구축 (0) | 2019.11.12 |