[LINUX] Redhat - Date & Time 설정
A real-time clock(RTC)는 일반적으로 hardware clock이라고 불리며, 현재 OS setting과 따로 가며 computer가 shutdown된 상태에서도 동작한다.
System clock - Software clock이라고 불리며 kernel에 의해 관리되고 최초 값은 real-time clock값이다. OS가 부팅되면 system clock이 initialized되고 real-time clock과는 완전히 독립적으로 움직인다.
system time은 상상 UTC(Coordinated Universal Time)을 유지하고 application에 따라 local time으로 변경된다.
timedatectl
date
hwclock
[root@localhost ~]# timedatectl
Local time: Tue 2017-05-02 18:59:10 KST
Universal time: Tue 2017-05-02 09:59:10 UTC
RTC time: Tue 2017-05-02 09:59:10
Time zone: Asia/Seoul (KST, +0900)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
chrony나 ntpd의 변경은 timedatectl에 바로 알림이 안되므로 이런 것들을 변경했으면 아래 command를 수행해 준다.
systemctl restart systemd-timedated.services
현재 시간을 변경하려면(time)
timedatectl set-time HH:MM:SS
시스템이 local-time을 유지하려면
timedatectl set-local-rtc yes(y, true, t or 1)
UTC를 유지하려면
timedatectl set-local-rtc no(n, false, f or 0)
현재 날짜를 변경하려면(date)
timedatectl set-time YYYY-MM-DD
timedatectl set-time '2017-05-02 23:01:00'
timezone을 변경하려면
timedatectl list-timezones
timedatectl set-timezone time_zone
ntp service도 조정가능
timedatectl set-ntp boolean
date명령어로 현재 시간 확인가능
utc로 확인하려면
date --utc(or date -u)
보여주는 형식을 바꾸고 싶으면
date +"format"
%H
%M
%S
%d
%m
%Y
%Z(timezone, ex. CEST)
%F full date format, ex. 2013-09-16
%T full time format, ex. 17:30:24
현재 시간 변경
date --set HH:MM:SS
date --set HH:MM:SS --utc
date --set 23:26:00
날짜 변경
date --set YYYY-MM-DD
date --set 2017-05-02 23:01:00
hwclock명령어
hardware clock에 접근(RTC)
setting은 /etc/adjtime file에 있음.
V6에서는 system shutdown시나 reboot시에 hwclock명령이 수행되었는데 7부터는 아님.
system clock이 NTP나 PTP랑 sync가 되는 경우는 kernel이 자동으로 11분마다 hardware clock을 system clock에 sync해준다.
hwclock --set --date "dd mmm yyyy HH:MM"
hw 시간을 current system time에 맞추려면
hwclock --systohc
system time을 hw clock에 맞추려면
hwclock --hctosys
hwclock을 current system time으로 설정하고 hwclock을 local time으로 유지하려면
hwclock --systohc --localtime
댓글
댓글 쓰기