setclock 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-setclock
핵심 정리
- 네트워크 시간 서버에 TIME 서비스(RFC 868, TCP 37번 포트) 요청을 보내 받은 시각을 보여 줍니다. root가 실행하면 시스템 시각도 그 값으로 맞춥니다.
setclock 서버처럼 서버를 주며, 없으면 기본 시간 서버(DNS 환경에서는 네임 서버가, 아니면/etc/hosts의timeserver항목)에 묻습니다.- 서버가 응답하지 않으면 메시지를 보여 주고 시각을 바꾸지 않습니다.
inetd의 내부 time 서비스가 켜진 호스트는 시간 서버가 될 수 있습니다.- 정밀도가 초 단위라 요즘은 NTP(
ntpdate,xntpd)를 주로 씁니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전의 내용이 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5 |
| 파일 | /usr/sbin/setclock, /etc/hosts |
| 관련 명령어 | ntpdate, xntpd, timed, date, inetd |
목적
네트워크 호스트의 시각과 날짜를 정합니다.
영어 원문
Sets the time and date for a host on a network.
구문
/usr/sbin/setclock [ TimeServer ]
설명
/usr/sbin/setclock 명령은 네트워크 시간 서버에서 시각을 받고, root 권한이 있는 사용자가 실행하면 로컬 시각과 날짜를 그에 맞춥니다.
시간 서버의 첫 응답을 받아 달력 시각으로 바꿔 로컬 날짜와 시각을 보여 줍니다. root가 실행하면 표준 워크스테이션 진입점을 불러 시스템 날짜와 시각을 정합니다.
응답하는 시간 서버가 없거나 네트워크가 동작하지 않으면 그런 내용의 메시지를 보여 주고 시스템의 날짜와 시각을 바꾸지 않습니다.
참고: inetd 데몬을 실행하는 호스트는 어느 것이든 시간 서버가 될 수 있습니다.
영어 원문
The /usr/sbin/setclock command gets the time from a network time server, and if run by a user with root user authority, sets the local time and date accordingly.
The setclock command takes the first response from the time server, converts the calendar clock reading found there, and displays the local date and time. If the setclock command is run by the root user, it calls the standard workstation entry points to set the system date and time.
If no time server responds or if the network is not operational, the setclock command displays a message to that effect and leaves the current date and time settings of the system unchanged.
Note: Any host running the inetd daemon can act as a time server.
Parameter
| 매개변수 | 설명 |
|---|---|
| TimeServer | TIME 요청을 처리하는 네트워크 호스트의 이름이나 주소. setclock은 그 호스트에 인터넷 TIME 서비스 요청을 보냅니다. 없으면 기본 시간 서버에 보냅니다. DOMAIN 환경에서는 네임 서버가 기본 시간 서버를 정하고, 아니면 /etc/hosts에서 정합니다. |
영어 원문
- TimeServer — The host name or address of a network host that services TIME requests. The setclock command sends an Internet TIME service request to a time server host. If the TimeServer name is omitted, the setclock command sends the request to the default time server. The default time server in a DOMAIN environment is specified by the name server. Otherwise the default time server is specified in the /etc/hosts file.
예제
/etc/hosts에 지정한 시간 서버로 날짜와 시각을 봅니다. 올바른 날짜와 시각이 나옵니다.
$ setclock
Sat Mar 11 15:31:05 1988
- 날짜와 시각을 맞춥니다. 시간 서버
host1에서 시각을 받아 맞추려면 먼저su로 root가 되거나 root로 로그인해야 합니다.
$ su root
# setclock host1
Thu Jan 12 15:24:15 1990
자주 쓰는 형태:
grep timeserver /etc/hosts # 기본 시간 서버 항목(예: 10.1.1.123 timeserver)
setclock 10.1.1.123 # 시각만 보기(root면 맞춤)
grep "^time" /etc/inetd.conf # 서버 쪽 inetd time 서비스 확인
ntpdate 10.1.1.123 # NTP로 맞추기(권장)
영어 원문
- To display the date and time using the time server host specified in the /etc/hosts file, enter:
setclock Sat Mar 11 15:31:05 1988
The setclock command displays the proper date and time.
- To set the date and time, enter:
su root setclock host1 Thu Jan 12 15:24:15 1990
You must use the su command or log in as the root user before setting the time from the time server in host1.
Related reference:
- timed Daemon
Related information:
- hosts File Format for TCP/IP
- inetd command
- su command
- TCP/IP daemons
리눅스(GNU)와 다른 점
리눅스에는 setclock이 없습니다. RFC 868 TIME 서비스로 맞추려면 rdate 서버(rdate 패키지)를 쓰고, 보통은 NTP(chronyd, chronyc makestep, ntpdate)나 timedatectl set-ntp true로 맞춥니다. 하드웨어 시계까지 맞추려면 hwclock -w를 씁니다.