1

Greetings,

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.

However, if TZ=America/Los_Angeles, or America/Chicago, then I know what the LOCAL timezone is set to.

But how do I know what the timezone Linux OS is running on? What does cron and other daemons base their timezone off of?

-daniel

Daniel
  • 175
  • 1
  • 6

3 Answers3

4

It's based off of the contents of /etc/localtime, which comes from one of the files in /usr/share/zoneinfo and can be changed with tzselect or system-config-date.

Ignacio Vazquez-Abrams
  • 45,019
  • 5
  • 78
  • 84
1

Just to add to what has been said already, hwclock will tell you the date according to the BIOS.

The BIOS date and the system's date can happen to be out of sync. When it comes to TZ, it is usual to set the BIOS time to UTC and let the system's date adjust its TZ, but some people prefer to set the BIOS time to their local time.

raphink
  • 11,337
  • 6
  • 36
  • 47
0

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 tzfileformat. 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...

sleske
  • 9,851
  • 4
  • 33
  • 44