DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 19th November 2023
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default clock syncing

How to adjust time? How to use OpenNTPD and configure it?
Reply With Quote
  #2   (View Single Post)  
Old 19th November 2023
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,321
Default

Quote:
Originally Posted by unicorn View Post
How to adjust time?
https://www.openbsd.org/faq/faq10.html#OpenNTPD

Quote:
How to use OpenNTPD and configure it?
https://man.openbsd.org/OpenBSD-7.4/rcctl.8
Reply With Quote
  #3   (View Single Post)  
Old 19th November 2023
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

sorry, I had read the first article but still confused. I want to auto sync time when booting. Which command should I run and add it to which file?
Reply With Quote
  #4   (View Single Post)  
Old 19th November 2023
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,100
Default

The ntpd(8) daemon is started on boot by default. It will automatically synchronize the local system clock using a pool of public NTP servers, and checks the supplied time's validity through a separate pool of public HTTPS servers acting as authentication constraints.

If OpenBSD's default time synchronization is not sufficient to your needs, you can use date(8) to set the clock manually or use rdate(8) to set the clock's time using a trusted remote NTP server.
Reply With Quote
  #5   (View Single Post)  
Old 19th November 2023
shep shep is offline
Real Name: Scott
Regex Recruiter
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,561
Default

OpenNTP is enabled out of the box as a default. Typically, it is within 200 msec and is substantially smaller and more secure (smaller attack surface and fewer cve's) than ntp which is a port option:
net/ntp

Last edited by shep; 27th February 2025 at 09:52 PM.
Reply With Quote
  #6   (View Single Post)  
Old 3rd February 2025
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

my system current time is Mon Feb 3 05:44:58 GMT 2025, I want to use Shanghai time, I had edit sysctl.conf and add this line:
Quote:
kern.utc_offset=+500
but I get top levels and second levels offset invalid errors.What's the appropriate parameter?
Reply With Quote
  #7   (View Single Post)  
Old 3rd February 2025
Onauk's Avatar
Onauk Onauk is offline
Real Name: Thomas
Shell Scout
 
Join Date: Jan 2023
Location: France
Posts: 88
Default

To change the timezone you should follow the OpenBSD FAQ[1].

Basically, do not change kern.utc_offset unless you want your hardware clock to be different than UTC, which is only important for multibooting.

To change the time zone to Shanghai you should do (as root) :

# ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[1] https://www.openbsd.org/faq/faq10.html#TimeZone
Reply With Quote
  #8   (View Single Post)  
Old 7th February 2025
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

thanks, I had executed that command but my time is still incorrect. I have two disks with OpenBSD and linux installed separately. How to do with it?
Reply With Quote
  #9   (View Single Post)  
Old 7th February 2025
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,100
Default

Both of your OSes should use UTC for the clock, with a local timezone offset. Windows is the only OS I'm aware of that needs the clock set to local time.
Reply With Quote
Old 8th February 2025
Head_on_a_Stick's Avatar
Head_on_a_Stick Head_on_a_Stick is offline
Real Name: Matthew
The Deliverator
 
Join Date: Dec 2015
Location: London
Posts: 495
Default

The ArchWiki claims that Ubuntu & Fedora will use localtime if they detect a Windows system when installing:

https://wiki.archlinux.org/title/Sys..._Ubuntu/Fedora

So if the OP had Windows on that machine when installing Linux they might have to change the Linux system to UTC:
Code:
timedatectl set-local-rtc 0
Then make sure the system clock is correct and update the hardware clock:
Code:
hwclock --systohc
__________________
Para todos todo, para nosotros nada
Reply With Quote
Old 27th February 2025
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

Sorry, I don't understand.
My time is 14:56 PM CST, system time is 08:56 AM GMT. I adjusted time use date command and I got 14:56 PM GMT. My time zone is CST not GMT.
Reply With Quote
Old 27th February 2025
shep shep is offline
Real Name: Scott
Regex Recruiter
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,561
Default

Most systems have a hardware clock and a system clock.

https://wiki.archlinux.org/title/System_time.

Unix/Linux based systems set the hardware clock to UTC which is preserved by the cmos battery when the system is powered off. On boot, the hardware clock is read and the system offset applied to generate system time, aka local time. The offset for CST is UTC-6.
NTP initially adjusts the System clock which, at some point, updates the hardware clock.

Windows sets the hardware clock to local time. This can have issues with emails sent from an Eastern Time zone, say at 4pm, which arrive at an Pacific Time zone at 1pm. Another issue is with security updates - most systems balk at security updates from the future

Last edited by shep; 2nd March 2025 at 01:16 AM.
Reply With Quote
Old 3 Weeks Ago
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

Quote:
Originally Posted by Onauk View Post
To change the timezone you should follow the OpenBSD FAQ[1].

Basically, do not change kern.utc_offset unless you want your hardware clock to be different than UTC, which is only important for multibooting.

To change the time zone to Shanghai you should do (as root) :

# ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[1] https://www.openbsd.org/faq/faq10.html#TimeZone
I had run that command and time is still GMT. What's wrong?
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,100
Default

Quote:
Originally Posted by unicorn View Post
I had run that command and time is still GMT. What's wrong?
Examine the output of:
Code:
$ ls -l /etc/localtime
This should be a symbolic link, pointing back to /usr/share/zoneinfo/Asia/Shanghai.
Reply With Quote
Old 2 Weeks Ago
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

Code:
ls -l /etc/localtime
Code:
lrwx-xr-x 1 root wheel 24 Oct 13 00:56 /etc/localtime -> /usr/share/zoneinfo/Asia
Code:
date
Code:
Tue Apr 8 06:14:57 GMT 2025
my time is 14:18 , April 8
Reply With Quote
Old 2 Weeks Ago
Onauk's Avatar
Onauk Onauk is offline
Real Name: Thomas
Shell Scout
 
Join Date: Jan 2023
Location: France
Posts: 88
Default

Quote:
Originally Posted by unicorn View Post
Code:
lrwx-xr-x 1 root wheel 24 Oct 13 00:56 /etc/localtime -> /usr/share/zoneinfo/Asia
This should redirect to /usr/share/zoneinfo/Asia/Shanghai as stated by jggimi.
Reply With Quote
Old 2 Weeks Ago
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

Why Shanghai is missing?
Reply With Quote
Old 2 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,100
Default

We cannot know what you did to cause the provisioning error. We're not there with you.

You should be able to correct the error with ln(1):
Code:
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
and then confirm you've corrected the error wlth with ls(1):
Code:
$ ls -l /etc/localtime
Reply With Quote
Old 2 Weeks Ago
unicorn unicorn is offline
Fdisk Soldier
 
Join Date: Apr 2020
Posts: 60
Default

I'm sorry Shanghai is still missing after those two commands executed
Reply With Quote
Old 2 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,100
Default

I'll guess. I will guess that you damaged the contents of /usr/share/zoneinfo/Asia/. That directory should contain 99 timezone files, starting with Aden and ending with Yerevan. I'll guess that you only have 98 files, and Shanghai has been moved or deleted.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unmounting/Syncing takes forever paulr NetBSD Installation and Upgrading 3 11th June 2017 03:43 AM
System clock's frequency e1-531g OpenBSD General 1 25th September 2015 05:03 PM
REQUEST: Programm for changing the clock m1tk0 Programming 3 16th January 2010 06:43 PM
configure clock in xfce delboy FreeBSD General 7 3rd September 2008 06:36 PM
can't set clock? carpman FreeBSD General 31 7th July 2008 11:26 PM


All times are GMT. The time now is 10:23 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick