How can I find the local timezone?
You can use the following as a guide to finding the local timezone for various systems depending on the distribution and release. If you change the timezone on a machine, you will at the least want to restart the cron daemon, whatever it is called on your machine, to pick up the change. You would generally be advised to reboot the system, so that all processes which are sensitive to the current time reflect the new timezone.
Windows
systeminfo | findstr /L Zone:
Linux
Ubuntu 14.04.3: cat /etc/timezone Ubuntu 16.04: cat /etc/timezone ls -l /etc/localtime | sed -e 's:.*zoneinfo/::' Ubuntu 18.04.4: cat /etc/timezone ls -l /etc/localtime | sed -e 's:.*zoneinfo/::' RHEL 5: sed -n -e '/ZONE/s:.*"\(.*\)":\1:p' /etc/sysconfig/clock CentOS 6, RHEL 6: sed -E 's:.*"(.*)":\1:' /etc/sysconfig/clock sed -n -E '/ZONE/s:.*"(.*)":\1:p' /etc/sysconfig/clock CentOS 7: ls -l /etc/localtime | sed -e 's:.*zoneinfo/::' CentOS 8: ls -l /etc/localtime | sed -e 's:.*zoneinfo/::' SLES 11: sed -n -e '/^TIMEZONE/s:.*"\(.*\)":\1:p' /etc/sysconfig/clock sed -n -e '/DEFAULT_TIMEZONE/s:.*"\(.*\)":\1:p' /etc/sysconfig/clock SLES 15: ls -l /etc/localtime | sed -e 's:.*zoneinfo/::' sed -n -e '/DEFAULT_TIMEZONE/s:.*"\(.*\)":\1:p' /etc/sysconfig/clock
Also with respect to keeping clocks synchronized over the long term, Linux used to use the ntpd daemon
(Network Time Protocol daemon) to keep the clock synchronized with Internet sources. Recent Linux releases have switched to using chronyd
for the same purpose. One or the other should be in play. There may be additional setup required in a virtual-machine environment.
Solaris
Solaris 10: sed -n -e 's/TZ=\(['"'"'"]*\)\(.*\)\1/\2/p' /etc/TIMEZONE Solaris 11.3: ls -l /etc/localtime | sed -e 's:.*zoneinfo/::'
The Linux and Solaris commands above will yield strings like the following:
America/New_York America/Los_Angeles US/Eastern
AIX
- The value exposed with this command has a complicated form; see
man environment
for details. - The timezone is generally not changed by direct editing of the
/etc/environment
file. On AIX 5.3 and lower, usesmit chtz
for that. On AIX 6.1 and 7.1, usesmit chtz_user
.
AIX 5.3: sed -n -e 's/TZ=\(.*\)/\1/p' /etc/environment