alog 명령어 (AIX 5.3·6.1)

핵심 정리

  • 표준 입력을 읽어 표준 출력에 쓰면서 고정 크기 파일에 복사합니다. 파일이 차면 가장 오래된 항목 위에 덮어쓰는 순환 로그입니다.
  • 로그는 -f 파일로 직접 지정하거나, alog 구성 데이터베이스(ODM SWservAt)에 정의된 로그 유형 -t 유형으로 지정합니다.
  • 가장 많이 쓰는 형태는 부팅 로그 보기 alog -t boot -o와 콘솔 로그 보기 alog -t console -o입니다. 정의된 유형 목록은 alog -L로 봅니다.
  • alog -C -t 유형 -s 크기는 ODM의 크기 값만 바꾸고 실제 파일 크기는 그대로입니다. 실제 크기도 바꾸려면 echo ... | alog -t 유형 -s 크기를 함께 합니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 -H(사용법)와 로그 파일 최대 2GB 안내가 더해짐)
원문 IBM Commands Reference — 5.3 Volume 1, 6.1 Volume 1
파일 /usr/bin/alog, /etc/objrepos/SWservAt, /var/adm/ras/bootlog, /var/adm/ras/conslog
관련 명령어 odmadd, odmget, bootinfo, swcons

목적

표준 입력으로 고정 크기 로그 파일을 만들고 관리합니다.

영어 원문

Creates and maintains fixed-size log files created from standard input.

구문

로그 파일 내용을 볼 때:

text
alog -f LogFile [ -o ]

지정한 로그 파일에 기록할 때:

text
alog -f LogFile | [ [ -q ] [ -s Size ] ]

로그 유형의 상세도(Verbosity) 값을 볼 때:

text
alog -t LogType -V

로그 유형의 속성을 바꿀 때:

text
alog -C -t LogType [ -f LogFile ] [ -s Size ] [ -w Verbosity ]

로그 유형의 현재 속성을 볼 때:

text
alog -L [ -t LogType ]

사용법을 볼 때(6.1):

text
alog -H

설명

alog 명령은 표준 입력을 읽어 표준 출력에 쓰고, 그 출력을 고정 크기 파일에 복사합니다. 이 파일은 순환 로그로 다뤄, 파일이 차면 새 항목을 가장 오래된 항목 위에 씁니다.

alog는 명령줄에 지정한 로그 파일이나 alog 구성 데이터베이스에 정의된 로그로 작업합니다. 구성 데이터베이스에 정의된 로그는 LogType으로 구분하며, LogType마다 File, Size, Verbosity 속성이 함께 저장됩니다. 새 LogType은 odmadd 명령으로 구성 데이터베이스에 더하고, 정의된 LogType의 속성은 alog 명령으로 바꿉니다.

영어 원문

The alog command reads standard input, writes to standard output, and copies the output into a fixed-size file. This file is treated as a circular log. If the file is full, new entries are written over the oldest existing entries.

The alog command works with log files that are specified on the command line or with logs that are defined in the alog configuration database. Logs that are defined in the alog configuration database are identified by LogType. The File, Size, and Verbosity attributes for each defined LogType are stored in the alog configuration database with the LogType. You can add a new LogType to the alog configuration database using the odmadd command. You can change the attributes of LogType defined in the alog configuration database using the alog command.

플래그

플래그 설명
-C 지정한 LogType의 속성을 바꿉니다. -f, -s, -w와 함께 써서 File, Size, Verbosity 속성을 바꾸며, -t LogType이 꼭 있어야 합니다. -C를 쓰면 표준 입력을 표준 출력이나 로그 파일에 복사하지 않습니다. root 권한이 필요합니다.
-f LogFile 로그 파일 이름. 없으면 만듭니다. 로그 파일에 쓸 수 없으면 /dev/null에 씁니다. -C, -t와 함께 쓰면 그 LogType의 File 속성을 바꿉니다.
-H 사용법을 보여 줍니다. 6.1부터
-L 구성 데이터베이스에 정의된 로그 유형을 나열합니다. -t LogType과 함께 쓰면 그 유형의 File, Size, Verbosity 값을 File:Size:Verbosity 형식으로 보여 줍니다. -L을 쓰면 표준 입력을 복사하지 않습니다.
-o 로그 파일의 내용을 순서대로 표준 출력에 씁니다.
-q 표준 입력을 로그 파일에 복사하되 표준 출력에는 쓰지 않습니다.
-s Size 로그 파일 크기 한도(바이트). 공간은 만들 때 예약합니다. 새 파일에 크기를 주지 않으면 최소 4096바이트이고, 이미 있는 파일이면 크기를 바꿉니다. 4096의 배수로 올림하며, 최대 2GB입니다(6.1 문서). 줄이면 새 크기에 맞지 않는 오래된 항목이 지워집니다. 크기를 바꾸려면 로그 파일 쓰기 권한이 필요합니다. -C, -t와 함께 쓰면 ODM의 Size 값만 바뀌고 실제 파일 크기는 그대로이며, 새 값은 다음에 로그 파일을 만들 때 쓰입니다.
-t LogType 구성 데이터베이스에 정의된 로그를 지정합니다. 파일 이름과 크기를 데이터베이스에서 가져오며, 파일이 없으면 만듭니다. 정보를 가져오지 못하거나 쓸 수 없으면 /dev/null에 씁니다. -f로 파일도 지정하면 -f를 쓰고 LogType은 무시합니다.
-V 그 LogType의 현재 Verbosity 값을 표준 출력에 씁니다. LogType이 없거나 정의되지 않았으면 아무것도 쓰지 않습니다. alog로 출력을 넘기는 명령이 이 값으로 출력할 상세도를 정할 수 있습니다.
-w Verbosity -C, -t와 함께 써서 Verbosity 속성(0~9)을 바꿉니다. 0이면 로그 파일에 아무것도 복사하지 않고 표준 출력에만 씁니다. 0이 아니면 들어온 정보를 로그 파일과 표준 출력 모두에 씁니다.

참고: console 로그 유형의 속성을 -C로 바꾸면 콘솔 로그 파일도 바뀌고 콘솔 장치 드라이버가 새 값을 쓰도록 갱신됩니다. 콘솔 로그 파일의 특수한 형식 때문에 보통의 alog -C 동작과 다르게 처리합니다.

영어 원문
  • -C — Changes the attributes for a specified LogType. Use the -C flag with the -f, -s, and -w flags to change the File, Size, and Verbosity attributes for the specified LogType. The -t LogType flag is required. Note: Using the -C flag with -sSize only changes the size value in ODM and does not change the size of the actual log file. If the -C flag is used, the alog command does not copy standard input to standard output or to a log file. When the -C flag is used to modify the attributes for the console log type, the console log file is also modified and the console device driver is updated to use the new values. This is a deviation from the normal operation of alog -C and is done to accommodate special formatting in the console log file. Note: You must have root user authority to change alog attributes.
  • -f LogFile — Specifies the name of a log file. If the specified log file does not exist, one is created. If the alog command is unable to write to a log file, it writes to /dev/null. Use the -f LogFile flag with the -C and -t flags to change the File attribute for a LogType defined in the alog configuration database.
  • -H — Displays the usage of the alog command.
  • -L — Lists the log types currently defined in the alog configuration database. If you use the -L flag with the -t LogType flag, the attributes for a specified LogType are listed. The current values of the File, Size, and Verbosity attributes are listed as colon separated values: <File>:<Size>:<Verbosity> If the -L flag is used, the alog command does not copy standard input to standard output or to File.
  • -o — Lists the contents of the log file. Writes the contents of the log file to standard output in sequential order.
  • -q — Copies standard input to a log file but does not write to standard output.
  • -s Size — Specifies the size limit of the log file in bytes. The space for the log file is reserved when it is created. If you create a new log file and do not specify the Size attribute, the minimum size, 4096 bytes, is used. If the log file already exists, its size will be changed. The size you specify is rounded upward to the next integral multiple of 4096 bytes. The maximum size for a log file is 2 GB. If the specified size is greater than 2 GB, only 2 GB is considered. If you decrease the size of the log file, the oldest entries in the log are deleted if they do not fit within the new size limit. You must have write permission for the log file to change its size. Use the -s Size flag with the -C and the -t flags to change the Size attribute for LogType defined in the alog configuration database. Only the size value in ODM is changed. The size of the actual log file remains the same. The new Size attribute value is used the next time a log file is created.
  • -t LogType — Identifies a log defined in the alog configuration database. The alog command gets the log's file name and size from the alog configuration database. If LogFile does not exist, one is created. If the alog command cannot get the information for the specified LogType from the alog configuration database or if the alog command is unable to write to LogFile, it writes to /dev/null. If you specify LogType and LogFile using the -f flag, LogFile is used and LogType is ignored.
  • -V — Writes the current value of the Verbosity attribute for LogType that is defined in the alog configuration database to standard output. If you do not specify LogType, or the LogType you specify is not defined, nothing is written to standard output. The value output using the alog command with the -t LogType and the -V flags can be used by a command that is piping its output to the alog command to control the verbosity of the data it writes to the pipe.
  • -w Verbosity — Changes the Verbosity attribute for LogType defined in the alog configuration database when used with the -C and the -t flags. The Verbosity attribute can have a value from 0 to 9. If the value is 0, no information is copied to LogFile by the alog command. All of the information is still written to standard output. If the value is not 0, all of the information piped to the alog command's standard input is copied to LogFile and to standard output.

예제

명령 하는 일
date | alog -f /tmp/sample.log 현재 날짜와 시간을 sample.log에 기록
alog -f /tmp/sample.log -o /tmp/sample.log의 내용 보기
echo "resizing log file" | alog -f /tmp/sample.log -s 8192 /tmp/sample.log의 크기를 8192바이트로
alog -C -t sample -f /var/sample.log 로그 유형 sample의 파일 이름을 /var/sample.log로

새 로그 유형 sample을 구성 데이터베이스에 더하려면 다음 형식의 alog.add 파일을 만들고 odmadd alog.add를 실행합니다. 그러면 SWservAt 데이터베이스에 더해집니다.

text
SWservAt:
   attribute="alog_type"
   deflt="sample"
   value="sample"
SWservAt:
   attribute="sample_logname"
   deflt="/tmp/sample.log"
   value="/tmp/sample.log"
SWservAt:
   attribute="sample_logsize"
   deflt="4096"
   value="4096"
SWservAt:
   attribute="sample_logverb"
   deflt="1"
   value="1"

부팅 로그의 크기를 8192바이트로 바꾸고 ODM에도 반영하려면 두 명령을 함께 씁니다.

bash
alog -C -t boot -s 8192
echo "Changed log size" | alog -t boot -s 8192

자주 쓰는 형태:

bash
alog -L                      # 정의된 로그 유형(boot, console, bosinst, nim 등)
alog -L -t boot              # 부팅 로그의 파일:크기:상세도
alog -t boot -o | more       # 부팅 로그 보기
alog -t console -o | tail    # 콘솔 로그 보기
영어 원문
  1. To record the current date and time in a log file named sample.log, enter: date | alog -f /tmp/sample.log

  2. To list the contents of /tmp/sample.log log file, enter:

alog -f /tmp/sample.log -o
  1. To change the size of the log file named /tmp/sample.log to 8192 bytes, enter:
echo "resizing log file" | alog -f /tmp/sample.log -s 8192
  1. To add a new log type sample to the alog configuration database, create the alog.add file in the following format:
SWservAt:
   attribute="alog_type"
   deflt="sample"
   value="sample"
SWservAt:
   attribute="sample_logname"
   deflt="/tmp/sample.log"
   value="/tmp/sample.log"
SWservAt:
   attribute="sample_logsize"
   deflt="4096"
   value="4096"
SWservAt:
   attribute="sample_logverb"
   deflt="1"
   value="1"

After creating the alog.add file, enter:

odmadd alog.add

This adds the alog.add file to the SWservAt database.

  1. To change the name of the log file for the log type sample to /var/sample.log in the alog configuration database, enter:
alog -C -t sample -f /var/sample.log
  1. To change the size of the boot log to 8192 bytes and reflect the new size in ODM, enter:
alog -C -t boot -s 8192
echo "Changed log size" | alog -t boot -s 8192

파일

파일 설명
/etc/objrepos/SWservAt 소프트웨어 서비스 보조 속성 객체 클래스(alog 구성 데이터베이스)
영어 원문
  • /etc/objrepos/SWservAt — Software Service Aids Attributes Object Class

Related information:

  • odmadd command
  • How to Add Objects to an Object Class

리눅스(GNU)와 다른 점

리눅스에는 같은 명령이 없습니다. 부팅·콘솔 메시지는 journalctl -b, dmesg로 보고, 크기가 정해진 순환 기록은 systemd 저널의 SystemMaxUse나 logrotate로 관리합니다. 명령 출력을 화면과 파일에 함께 남기는 용도라면 tee -a 파일이 가깝지만 크기 제한과 순환은 없습니다.