The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.
System time is based on the POSIX time standard, where time is measured as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970. A day is defined as 86400 seconds and leap seconds are subtracted automatically.
Date and time representation on a system can be set to match a
specific timezone. Zone information files are stored in
/usr/share/zoneinfo
. Typically, the zone files
are organized in subdirectories named for each region. The
following commands allow you to view all of the zone information
files available:
#cd /usr/share/zoneinfo
#ls -lR
To set the system timezone for a particular zone, you must copy
the appropriate zone file to overwrite
/etc/localtime
. It is important that you also
update the /etc/sysconfig/clock
file to match
the timezone that you have set, so that other applications can
determine which zone information file you are using. This is best
achieved by editing the /etc/sysconfig/clock
file and then running the tzdata-update
command. For example:
#sed -i "\|ZONE=|c\ZONE=
#America/Los_Angeles
" /etc/sysconfig/clocktzdata-update
Substitute America/Los_Angeles
with a
valid timezone entry. The setting takes effect immediately. Some
long running processes that might use
/etc/localtime
to detect the current system
timezone, may not detect a subsequent change in system timezone
until the process is restarted.
Note that timezones are largely used for display purposes or to
handle user input. Changing timezone does not change the time for
the system clock. You can change the presentation for system time
in any console by setting the TZ
environment
variable. For example, to see the current time in Tokyo, you can
run:
# TZ="Asia/Tokyo
" date
To set system time manually, you can use the date command. For example. you can run:
# date -s "2018-10-28 01:59:59
"
This command sets the current system time based on the time specified assuming the currently set system timezone. The command does not update the system Real Time Clock (RTC). You can set the system RTC to match the current system date and time using the hwclock command. For example:
#hwclock --show
#hwclock --systohc --utc
Consider configuring your system to use network time synchronization for accurate time-keeping. This can be particularly important when setting up high-availability or when using network-based file systems. See Chapter 14, Network Time Configuration for more information on configuring network time services that use NTP.