- timedatectl


root@ip-10-90-10-20:/root> timedatectl

      Local time: Thu 2017-03-16 01:54:16 UTC

  Universal time: Thu 2017-03-16 01:54:16 UTC

        RTC time: Thu 2017-03-16 01:54:16

       Time zone: UTC (UTC, +0000)

     NTP enabled: yes

NTP synchronized: yes

 RTC in local TZ: no

      DST active: n/a

root@ip-10-90-10-20:/root>


root@ip-10-90-10-20:/root> systemctl restart systemd-timedated

root@ip-10-90-10-20:/root>




root@ip-10-90-10-20:/root> timedatectl --help

timedatectl [OPTIONS...] COMMAND ...


Query or change system time and date settings.


  -h --help                Show this help message

     --version             Show package version

     --no-pager            Do not pipe output into a pager

     --no-ask-password     Do not prompt for password

  -H --host=[USER@]HOST    Operate on remote host

  -M --machine=CONTAINER   Operate on local container

     --adjust-system-clock Adjust system clock when changing local RTC mode


Commands:

  status                   Show current time settings

  set-time TIME            Set system time

  set-timezone ZONE        Set system time zone

  list-timezones           Show known time zones

  set-local-rtc BOOL       Control whether RTC is in local time

  set-ntp BOOL             Control whether NTP is enabled

root@ip-10-90-10-20:/root>


ex. 저녁 10시 10분 10초로 변경
timedatactl set-time 22:10:10


ex. 1981년 6월 26일 져녁 9시 20분 15초

timedatactl set-time '1981-06-26 21:20:15'



사용 가능한 타임존 확인

root@ip-10-90-10-20:/root> timedatectl list-timezones

Africa/Abidjan

Africa/Accra

Africa/Addis_Ababa



타임존 변경

root@ip-10-90-10-20:/root> timedatectl list-timezones | grep Seoul
Asia/Seoul
root@ip-10-90-10-20:/root> timedatectl set-timezone Asia/Seoul
root@ip-10-90-10-20:/root> timedatectl
      Local time: Thu 2017-03-16 11:06:20 KST
  Universal time: Thu 2017-03-16 02:06:20 UTC
        RTC time: Thu 2017-03-16 02:06:19
       Time zone: Asia/Seoul (KST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

root@ip-10-90-10-20:/root> timedatectl set-timezone UTC
root@ip-10-90-10-20:/root> timedatectl
      Local time: Thu 2017-03-16 02:06:34 UTC
  Universal time: Thu 2017-03-16 02:06:34 UTC
        RTC time: Thu 2017-03-16 02:06:33
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a


NTP 활성화


root@ip-10-90-10-20:/root> timedatectl set-ntp yes



 - date


root@ip-10-90-10-20:/root> date

Thu Mar 16 02:10:27 UTC 2017


root@ip-10-90-10-20:/root> date --utc
Thu Mar 16 02:14:23 UTC 2017
root@ip-10-90-10-20:/root>

date +"format"

Control SequenceDescription
%HThe hour in the HH format (for example, 17).
%MThe minute in the MM format (for example, 30).
%SThe second in the SS format (for example, 24).
%dThe day of the month in the DD format (for example, 16).
%mThe month in the MM format (for example, 09).
%YThe year in the YYYY format (for example, 2013).
%ZThe time zone abbreviation (for example, CEST).
%FThe full date in the YYYY-MM-DD format (for example, 2013-09-16). This option is equal to %Y-%m-%d.
%TThe full time in the HH:MM:SS format (for example, 17:30:24). This option is equal to %H:%M:%S

root@ip-10-90-10-20:/root> date +"%Y-%m-%d %H:%M"
2017-03-16 02:16


root@ip-10-90-10-20:/root> date --set HH:MM:SS
root@ip-10-90-10-20:/root> date --set HH:MM:SS --utc
root@ip-10-90-10-20:/root> date --set YYYY-MM-DD


 - hwclock

root@ip-10-90-10-20:/root> hwclock
Thu 16 Mar 2017 02:23:00 AM UTC  -0.050245 seconds
root@ip-10-90-10-20:/root>


root@ip-10-90-10-20:/root> hwclock --help

Usage:
 hwclock [function] [option...]

Functions:
 -h, --help           show this help text and exit
 -r, --show           read hardware clock and print result
     --set            set the RTC to the time given with --date
 -s, --hctosys        set the system time from the hardware clock
 -w, --systohc        set the hardware clock from the current system time
     --systz          set the system time based on the current timezone
     --adjust         adjust the RTC to account for systematic drift since
                        the clock was last set or adjusted
 -c, --compare        periodically compare the system clock with the CMOS clock
     --getepoch       print out the kernel's hardware clock epoch value
     --setepoch       set the kernel's hardware clock epoch value to the
                        value given with --epoch
     --predict        predict RTC reading at time given with --date
 -V, --version        display version information and exit

Options:
 -u, --utc            the hardware clock is kept in UTC
     --localtime      the hardware clock is kept in local time
 -f, --rtc <file>     special /dev/... file to use instead of default
     --directisa      access the ISA bus directly instead of /dev/rtc
     --badyear        ignore RTC's year because the BIOS is broken
     --date <time>    specifies the time to which to set the hardware clock
     --epoch <year>   specifies the year which is the beginning of the
                        hardware clock's epoch value
     --noadjfile      do not access /etc/adjtime; this requires the use of
                        either --utc or --localtime
     --adjfile <file> specifies the path to the adjust file;
                        the default is /etc/adjtime
     --test           do not update anything, just show what would happen
 -D, --debug          debugging mode

root@ip-10-90-10-20:/root>

하드웨어 시간을 현재 시스템 시간으로 설정
hwclock --systohc 

시스템 시간을 하드웨어 시간으로 설정
gwclock --hctosys



'Linux > Redhat 7 system administrator's guide' 카테고리의 다른 글

8. YUM  (0) 2017.08.01
5. GAINING PRIVILEGES  (0) 2017.07.14
4. ACCESS CONTROL LISTS  (0) 2017.07.11
3. MANAGING USERS AND GROUPS  (0) 2017.07.05
1. system locale and keyboard configuration  (0) 2017.03.16

+ Recent posts