[SOLVED] What is wrong with this computer time + Debian 9?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This computer has Debian 9 running. For window manager, it has Mate installed, among others.
Why does it always shows date and time in a different timezone?
Why does it also does *not* accept that I change the clock? I changed the clocked with the root account, click "ok" to close the window with the changes, and it is ignored!
I have tried to change the settings with several usual methods, none of them worked:
- reboot and change in BIOS.
- change with a normal user that can do sudo
- change with root account
Even at the moment that I change the clock settings, it is ignored as if I did not even try.
More details will be given as you ask. I do not know much details about this computer.
Depending on how things go - each user is allowed to have their own timezone determined when they log in.
Changing the systems desigation for time zone doesn't change the users designation - and that would occur when the user logs in. Thus a logout/login should get the new default.
The problem is that I do not know what to look for, nor where to look.
I have tried something that I did not do before: rebooted the computer, changed the clock in BIOS (which where a few hours ahead), removed the network cable, logged in as a normal user. The clock is correct! Logged out and in again with the network cable there, it did not change anymore. Maybe just after another reboot. But remember: it also will prevent changes after any user log in.
Why does it always shows date and time in a different timezone?
Could you clarify what exactly you mean by this? Does it show different timezones for different users or does the timezone for an individual user change randomly?
What are the outputs of these two commands (depending on the distro, you may have to run one or more of them as root):
Code:
# date
# hwclock
Be sure to surround any command output with "code" tags, which become available when you click the "Go Advanced" button at the bottom of the "compose post" window.
Why does it always shows date and time in a different timezone?
When I log in with a graphical interface, the window manager (Mate) show the clock a few hours wrong. I can see it the right time, just a few hours wrong. This happened everytime I used it. The first time it happened differently was a few minutes ago, when I did a complete boot with no network access (literally, removed cable).
hwclock... I did not know that one. I will show you a bit more. Right now, I am accessing this machine with ssh. In my PS1, I have the time with seconds, user@machine and current folder shown, and the command on a separate line. Look what it showed:
Code:
22:19:19 [ 255] me@anotherComputer: ~ # this was the current time ~one hour ago,
# in my timezone and computer
$ ssh user@192.168.local.net
Debian GNU/Linux 9
user@192.168....'s password:
Linux debian 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64
Debian 9 = Stretch
No mail.
Last login: Sat Sep 23 17:48:30 2017
19:00:59 [ 0] user@debian: ~ # should have been 23:00
$ date
Sat Sep 23 19:01:13 PDT 2017
19:01:13 [ 0] user@debian: ~
$ hwclock
-bash: hwclock: command not found
19:01:58 [ 1] user@debian: ~
$ su
Password:
19:02:18 [ 0] root@debian: /home/user
# hwclock
2017-09-23 19:06:14.697298-0700
19:03:15 [ 0] root@debian: /home/user
# exit
19:06:35 [ 0] user@debian: ~
$ date
Sat Sep 23 19:06:42 PDT 2017
19:06:42 [ 0] user@debian: ~
$
Is that 0700 a timezone? Due this fact, I have checked: the same user, logged in graphically, have the 19:2x clock shown. And when I click on the Mate clock, it shows the BR time (which is the one and only location I have for this user's settings) correct: 23:2x.
(just loose thought writing: What changed the hwclock again? I want it different. Or did I adjust it wrong? ...)
It's late here in EDT and I have to pack it in, but the -0700 would normally indicate the difference from Universal Mean Time (what used to be called Greenwich Mean time) represented by the PDT timezone.
-0400 is EDT. (-0500 is EST.)
There's a neat little command line program called tzselect that you can use to check your timezone setting. It needs to be run as root. It is likely already installed.
The -0700 would normally indicate the difference from Universal Mean Time (what used to be called Greenwich Mean time) represented by the PDT timezone.
-0400 is EDT.
-0400 is my timezone now, BRT (I think these are the letters I would choose). I am in Brasil. I did not know date showed timezone with letters... should have been easy to learn - if I suspected it was there, I just passed my eyes through it without paying attention.
But why the computer seems locked to this strange (to me) timezone? Changing the hardware clock is useless while it has a network connection to correct it (probably using NFS?). I do not even know what to search for, without finding only results for things not my problem.
- talks about /etc/adjtime, which has the 3rd line written UTC
- talks about tzset(3), which is a function (programming), but I found tzselect program!
'man tzselect' says:
"Note that tzselect will not actually change the timezone for you. Use 'dpkg-reconfigure tzdata' to achieve this."
Should I do that dpkg-r... command?
'man hwclock' also mentioned "ISA hardware clock". How can I find if my hardware has this kind of feature, or anything similar? A couple of days ago, I have read everything I could understand in the BIOS options of this computer. Nothing seemed to fit my problem of "OS with a different timezone", and I changed the clock there again, assuming it should be "my clock, in my timezone", as it was with all computers I used before (at least, or I could not tell).
To see or change what timezone your Debian system is configured for,
# dpkg-reconfigure tzdata
What does this do? It changes /etc/localtime. Background information follows.
So, can I say that /etc/localtime was the file I should have known before? With the command, I saw that the timezone for this computer was Los Angeles'. Now it is correct, and probably will not be wacky anymore.
Right? If there are no more comments or things I should know, the thread will be marked as solved.
So, can I say that /etc/localtime was the file I should have known before?
Yes, but in most cases /etc/localtime is not a file, but a symlink to one of the files in /usr/share/zoneinfo.
Depending on where you are in Brazil, it should be a link to either of the files Porto_Acre, Noronha, Sao_Paulo or Manaus in /usr/share/zoneinfo/America.
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,363
Rep:
Hi Dedec0,
Although I am not a Debian user, your issue sounds like a typical case of a computer being incorrectly configured with respect to local time or UMT.
Basically, in linux, unless configured specifically otherwise, the linux system expects the computer's hardware clock to be interpreted as UMT. It then knows which time to display to the user depending on the time zone the user has configured.
So in a nutshell:
- Make sure your linux is configured properly to interpret your hardware clock. As mentioned above, it normally expects this to be UMT. It can be configured to interpret it as local time, but the appropriate command is required to do this (since this is not typical, I'll leave you to let us know if you need help with this function).
- Make sure your computer is properly configured with respect to its time zone. This is usually initially done at system install, but obviously can be changed if you travel. In Arch (the system I use), this is done on the command line, but Debian probably has a GUI tool to manage this.
Hope this helps - let us know if more assistance is needed.
As others have said, /etc/localtime should either contain the proper default local time, or be a symbolic link to the right one. I like the use of the symbolic link as the info in /usr/share/zoneinfo/... documents what timezone you have without having to decode the contents (it is a binary file).
Exactly, TobiSGD. I have checked /usr/share/zoneinfo files yesterday and found symlinks to the files you mention. After doing that, I decided to change my timezone and ran:
Code:
# dpkg-reconfigure tzdata # see/change what TZ system is configured for
Current default time zone: 'America/Sao_Paulo'
Local time is now: Sun Sep 24 02:13:53 -03 2017.
Universal Time is now: Sun Sep 24 05:13:53 UTC 2017.
Right now I checked /etc/localtime, and it is also simply a symlink to the correct zoneinfo file, based on what dpkg-reconfigure did.
Note that I made a mistake in the posts above: my timezone is -3, not -4.
Rickkkk, thank you for all your comments. I have some doubts with them. First, I searched around a bit, but could not find a page with enough comments to what I want: configure this computer to use its hardware clock as localtime (for it is better); from the pages I have read (skimmed, some were too long), it can be a Debian configuration, a specific kernel configuration. May you help me doing that?
First good looking page I found was stack ov. /.../set-hwclock-to-utc-on-linux. The opposite wish, but that should be easy to change. It made me read 'man hwclock' more carefully for a few options. '/etc/sysconfig/clock' file does not exist here.
So, in the end I still have doubts. I want to: use computer's clock as localtime in all installed OSes, if it is not yet doing so; configure this Debian install to know that, and work according to that. Debian may change the hardware clock with NTP if it gets a bit wrong. All of this may involve global system settings, kernel settings or anything else I did not mention. I want to be sure that every possible detail is corret. May you help me here?
Right now, I ran the same commands frankbell asked above, and one more that I think can be useful to helpers now, with all I already did:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.