2

After manual installation with debootstrap my server always uses the local time. I've already tried to set the timezone to UTC, but it didn't worked. The timezone was set with the following command:

cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime

I would like to force the servers to always use UTC as the timezone.

date

Mo 4. Jun 13:08:51 CEST 2018

date -u

Mo 4. Jun 11:09:07 UTC 2018

ls -al /etc/localtime

lrwxrwxrwx 1 root root 23 Jun  4 13:09 /etc/localtime -> /usr/share/zoneinfo/UTC

cat /etc/timezone

Etc/UTC

timedatectl

Local time: Di 2018-06-05 14:52:12 CEST
Universal time: Di 2018-06-05 12:52:12 UTC
RTC time: Di 2018-06-05 12:52:12
Time zone: Etc/UTC (CEST, +0200)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

I've already tried to configure the timezone by the following commands with no effect:

dpkg-reconfigure tzdata
cp /usr/share/zoneinfo/UTC /etc/localtime
ln -s /etc/localtime /usr/share/zoneinfo/UTC
ln -s /etc/localtime /usr/share/zoneinfo/Etc/UTC

I can't see any warning or error messages.

Do you have an idea what could be the reason for the wrong time zone?

  • Please add output of timedatectl to your question. – Pilot6 Jun 5 '18 at 12:48
  • OK, then post the full output of timedatectl. It should show what is the problem. At least we know that systemd is used. – Pilot6 Jun 5 '18 at 12:51
6

The problem might be this link:

lrwxrwxrwx 1 root root 23 Jun  4 13:09 /etc/localtime -> /usr/share/zoneinfo/UTC

If this link was present before the cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime command, what actually happened was that the /usr/share/zoneinfo/UTC file was overwritten by the contents of file /usr/share/zoneinfo/Europe/Berlin.

That would cause anything that actually uses the contents of the /etc/localtime file to use the CET/CEST timezone, but anything that looks up the timezone by just checking the name of the linked file would report the timezone as "UTC".

To fix it:

apt-get --reinstall install tzdata
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
update-initramfs -u

Note the last command: after changing the system default timezone you should update your initramfs, to ensure that also the processes that start early in the system boot sequence will use the correct timezone definition.

  • Thanks! apt-get --reinstall install tzdata fixed it – JanW Jun 5 '18 at 13:09
  • See my update about updating initramfs too, to ensure that all system processes will use the new timezone. – telcoM Jun 5 '18 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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