yeonghoon.kim

  • 게시판
  • 갤러리
  • aws

logger - 커스텀 로그 찍기

김영훈 2019.11.28 15:34 조회 수 : 283

1. 사용법

Usage:
 logger [options] [<message>]

Enter messages into the system log.

Options:
 -i                       log the logger command's PID
     --id[=<id>]          log the given <id>, or otherwise the PID
 -f, --file <file>        log the contents of this file
 -e, --skip-empty         do not log empty lines when processing files
     --no-act             do everything except the write the log
 -p, --priority <prio>    mark given message with this priority
     --octet-count        use rfc6587 octet counting
     --prio-prefix        look for a prefix on every line read from stdin
 -s, --stderr             output message to standard error as well
 -S, --size <size>        maximum size for a single message
 -t, --tag <tag>          mark every line with this tag
 -n, --server <name>      write to this remote syslog server
 -P, --port <port>        use this port for UDP or TCP connection
 -T, --tcp                use TCP only
 -d, --udp                use UDP only
     --rfc3164            use the obsolete BSD syslog protocol
     --rfc5424[=<snip>]   use the syslog protocol (the default for remote);
                            <snip> can be notime, or notq, and/or nohost
     --sd-id <id>         rfc5424 structured data ID
     --sd-param <data>    rfc5424 structured data name=value
     --msgid <msgid>      set rfc5424 message id field
 -u, --socket <socket>    write to this Unix socket
     --socket-errors[=<on|off|auto>]
                          print connection errors when using Unix sockets
     --journald[=<file>]  write journald entry

 -h, --help               display this help
 -V, --version            display version

For more details see logger(1).


2. 사용 예시

#!/bin/bash

HELLO_ROOT=$(echo "[ $( hostname -I )] $(date '+%Y-%m-%d %H:%M:%S') ROOT_LOGIN - $(w | awk '{ print $3 }' | tail -n 1)")
CONNECT_USER=$(w | grep pts | wc -l)

if [ "${CONNECT_USER}" -ge 1 ]
then
    logger -p local6.notice -t HELLO_ROOT ${HELLO_ROOT}
fi


3. 적용 확인(/var/log/messsage)

Nov 28 14:17:41 localhost HELLO_ROOT[5436]: [ 10.101.0.10 ] 2019-11-28 14:17:41 ROOT_LOGIN - xxx.xxx.xxx.xxx  

  • 추천 0

  • 비추천 0
이 게시물을
목록

댓글 0

사진 및 파일 첨부

여기에 파일을 끌어 놓거나 왼쪽의 버튼을 클릭하세요.

파일 용량 제한 : 0MB (허용 확장자 : *.*)

업로드 중... (0%)

0개 첨부 됨 ( / )
 
번호 제목 글쓴이 날짜 조회 수
공지 2025 일본 여행 계획 김영훈 2024.10.10 1310
공지 현금, 저축, 투자, 지출, 예산, 보험 내역(2024-05-30) 김영훈 2024.03.10 1032
226 CentOS7 메일 서버 구축 #2 - Dovecot 설치 및 설정 김영훈 2019.11.10 128
225 CentOS7 메일 서버 구축 #3 - 도메인 레코드 설정 및 수발신 테스트 김영훈 2019.11.10 156
224 CentOS7 BIND 1차, 2차 구성 김영훈 2019.11.10 111
223 CentOS7 MariaDB 설치 및 설정(RPM) 김영훈 2019.11.10 145
222 CentOS7 Google Authenticator(구글 OTP) SSH 적용 김영훈 2019.11.10 160
221 이온큐브 디코더 - https://easytoyou.eu 김영훈 2019.11.10 337
220 sendmail 메일 발송 확인 스크립트 김영훈 2019.11.13 234
219 sendmail 스팸 리스트에 올라간 것 해제 - stat=Deferred: 421 Your ip is filtered by RBL.(IP:xxx.xxx.xxx.51)(Caues:https://www.spamhaus.org/query/ip/xxx.xxx.xxx.51) 김영훈 2019.11.14 278
218 sendmail 버전 숨기기 김영훈 2019.11.14 300
217 ansible 파일 배포 후 크론 등록.yml 김영훈 2019.11.15 172
216 nginx 설정에서 특정 User-Agent 차단 김영훈 2019.11.15 423
215 ls 시간 표시 지정 김영훈 2019.11.18 201
214 메일서버 SSL 적용(sendmail, dovecot) 김영훈 2019.11.18 294
213 dovecot imaps(993) 비활성화 김영훈 2019.11.18 264
212 smtp ip 차단 스크립트 김영훈 2019.11.19 177
211 svn 인증 시 yes를 입력해도 다시 물을 경우 김영훈 2019.11.20 501
210 엑셀 취소선 단축키 - Ctrl+5 김영훈 2019.11.21 153
209 centos8 ncdu 설치(source) 김영훈 2019.11.28 311
» logger - 커스텀 로그 찍기 김영훈 2019.11.28 283
207 제주 여행 요약(20191220~20191223) 김영훈 2019.12.24 222
쓰기 태그
 첫 페이지 1 2 3 4 5 6 7 8 9 10 끝 페이지