Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.