Skip to main content
Topic: make Artix use hardware time instead of UTC (Read 3475 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

make Artix use hardware time instead of UTC

I dual boot Artix, Kubuntu and Windows. On kubuntu I used timedatectl to make it use hardware time instead of using UTC. I don't want to make Windows use UTC.

Now the problem is Artix still uses UTC and this desyncs my clock by 8 hours. I used timeset-gui to make it use hardware time, but it doesn't work. My time is still changed after reboot.

However, I noticed that when I shut down / reboot, there was a line saying 'Syncing to hardware clock' or something similiar. I suspect that it was the culprit, but I have no idea what it is and how to disable/configure it.

Any help is appreciated.
You shouldn't listen to my advice anyways

Re: make Artix use hardware time instead of UTC

Reply #1
Hello,
if you are using OpenRC you can use service "hwclock" and than configure it at /etc/conf.d/hwclock

Re: make Artix use hardware time instead of UTC

Reply #2
Nope, I am using runit.
You shouldn't listen to my advice anyways


Re: make Artix use hardware time instead of UTC

Reply #4
Actually, you can edit the rc.conf file and change HARDWARECLOCK to "localtime" which is what I believe you want. I forgot where exactly the file is located on runit though (/etc/rc.conf)?

Re: make Artix use hardware time instead of UTC

Reply #5
Quote
Actually, you can edit the rc.conf file and change HARDWARECLOCK to "localtime" which is what I believe you want. I forgot where exactly the file is located on runit though (/etc/rc.conf)?

Found it in Artix wiki, it was
Code: [Select]
/etc/rc/rc.conf

I tried both of your suggestions. Howvever, it just doesn't work. [/etc/adjtime] kept being changed to UTC after boot.
You shouldn't listen to my advice anyways

 

Re: make Artix use hardware time instead of UTC

Reply #6
SO it should go back to UTC not local time. You could of course config Windows to use UTC problem solved as Ms is the problem not Linux, Unix, including Mac.

Re: make Artix use hardware time instead of UTC

Reply #7
https://wiki.gentoo.org/wiki/System_time
It's probably being set by the kernel, the Artix kernel is configured to do this. hwclock is there for legacy / compatibility reasons, you can disable the service if you want in most cases I think. Not sure how to get it to set the time you want :D

Re: make Artix use hardware time instead of UTC

Reply #8
SO it should go back to UTC not local time. You could of course config Windows to use UTC problem solved as Ms is the problem not Linux, Unix, including Mac.
Well,
Quote
I don't want to make Windows use UTC.
I did mention I don't want Windows to use UTC because one thing is, everytime when Windows updates, registry might got mess up real bad. I don't see these kinds of problems with Linux (Or at least now).

https://wiki.gentoo.org/wiki/System_time
It's probably being set by the kernel, the Artix kernel is configured to do this. hwclock is there for legacy / compatibility reasons, you can disable the service if you want in most cases I think. Not sure how to get it to set the time you want :D
Geez, that's PITA.


I think I will leave this thread as it is. I don't know if I should consider it to be solved or not.
I will make Windows use UTC in this case, but still, it'll be cool if we can find a solution for this without involving kernel compilation.
I compiled them once spent nights figuring out how to make them work  :'(
You shouldn't listen to my advice anyways

Re: make Artix use hardware time instead of UTC

Reply #9
Well,I did mention I don't want Windows to use UTC because one thing is, everytime when Windows updates, registry might got mess up real bad. I don't see these kinds of problems with Linux (Or at least now).
Geez, that's PITA.


I think I will leave this thread as it is. I don't know if I should consider it to be solved or not.
I will make Windows use UTC in this case, but still, it'll be cool if we can find a solution for this without involving kernel compilation.
I compiled them once spent nights figuring out how to make them work  :'(

Can i just add this I lived in Peru for 8 years Uk British keyboard, UK local.So windows left to its own devices would change the hardware clock to UK local time.
Why the would I want UK time in another country but you can't tell window just because you use a UK keyboard and UK language you don't want UK time. Mac, Linux, has no problem default is UTC only stupid Windows.

Re: make Artix use hardware time instead of UTC

Reply #10
https://venam.nixers.net/blog/unix/2020/05/02/time-on-unix.html
https://fitzcarraldoblog.wordpress.com/2014/09/30/configuring-the-linux-clock/
Also see hwclock man page.
It seems there is a kernel variable called "persistent_clock_is_local", an int, in RAM, that defaults to UTC. So for UTC you don't need to do anything. But for localtime you need to set it at boot or at least sometime before the kernel writes the time to the BIOS clock, which might be at shutdown or more often if you were using NTP. Running hwclock can set it to localtime, apparently the kernel may not check any files itself about this and you have to tell it. So possibly enabling the hwclock service, or just causing the appropriate hwclock command (whatever that might be exactly) to be run at boot somehow would inform the kernel the BIOS clock is supposed to be set to localtime and it won't set it to UTC when you shut down. Systemd has some timedatectl thing.
I'm just using UTC and NTP and it all worked without much bother which is why I don't know exactly. But I doubt you need to recompile the kernel.  :D

Re: make Artix use hardware time instead of UTC

Reply #11
OK, I got this to work with OpenRC like this:

Code: [Select]
1) Edited /etc/conf.d/hwclock:
# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as
# Greenwich Mean Time).  If that clock is set to the local time, then
# set CLOCK to "local".  Note that if you dual boot with Windows, then
# you should set it to "local".
clock="local"
#clock="UTC"

# If you want the hwclock script to set the system time (software clock)
# to match the current hardware clock during bootup, leave this
# commented out.
# However, you can set this to "NO" if you are running a modern kernel
# and using NTP to synchronize your system clock.
#clock_hctosys="YES"

# If you do not want to set the hardware clock to the current system
# time (software clock) during shutdown, set this to no.
#clock_systohc="YES"

# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here. Alpha users may wish to use --arc or --srm here.
clock_args=""

2) Added hwclock sercice to boot runlevel:
$ sudo rc-update add hwclock boot

Then I shut down, went into the BIOS when I restarted and set the clock in the BIOS menu to localtime. And it has worked, I can boot and shutdown with or without a network connection and the time stays like that.
But it is confusing because in /etc/conf.d/hwclock it says:
# However, you can set this to "NO" if you are running a modern kernel
# and using NTP to synchronize your system clock.
#clock_hctosys="YES"
And on the Gentoo wiki it says:
OpenRC
When using OpenRC the hwclock init script can set the system clock on boot and sync system time to the hardware clock on shutdown. The service is enabled by default and should be disabled in favor of the above mentioned in-kernel method. The hwclock script should not be run when using the kernel's real time clock.

But that information is WRONG if you want to use localtime, as the hwclock man page explains:
 The  first  userspace  command  to set the System Clock informs the kernel what timescale the Hardware Clock is using.  This happens via the persistent_clock_is_local
       kernel variable.  If --hctosys or --systz is the first, it will set this variable according to the adjtime file or the appropriate command-line argument.

You have to send a set command with hwclock of some sort to set the kernel variable so when you use localtime you can't just rely on the kernel. That advice must have been written by people who only used UTC.

I don't have any /etc/adjtime file incidentally. Now you just need to figure out how to do that in Runit  ;D