I am trying to find out what timezone
the operating system/bios clock? is
running in. The problem is that if TZ is
missing or empty, I suspect that date
and ls revert to TZ=UTC.
No, this is not correct. date, ls, and just about all other software don't just revert to UTC when TZ is unset, they use the defaul timezone. On Linux, the default timezone is set in the file /etc/localtime
. There's little point looking into the file, it's a binary file in tzfile
format. It is either a symlink to or a copy of one of the files under /usr/share/zoneinfo
; these are the rules for different timezones.
But how do I know what the timezone Linux OS is running on?
If /etc/localtime
is a symlink, just see where it points. If it's a file, it's best to use your distro's tools to find out. Under Debian, use
dpkg-reconfigure tzdata
(just press Cancel right away to not change anything).
On RedHat, it's redhat-config-date
or system-config-date
.
What does cron and other daemons base their timezone off of?
Most daemons simply use the system default time zone.
Cron, unfortunately, is something of a special case: There are several implementations, which handle timezones differently. "Vixie cron", which is the usual cron on Linux, just always uses the default time zone. Some crons (e.g. on BSD) allow you to switch the time zone in the crontab. Whether this is an improvement is debatable...