LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-03-2022, 02:51 PM   #1
PsychoHermit
Member
 
Registered: Aug 2021
Location: Carson City Nevada
Distribution: Debian Testing
Posts: 137

Rep: Reputation: Disabled
How to synchronize time


Greetings folks,

My clock is off. I am running ubuntu 20.04.3 LTS. I installed systemd-timesyncd and opened port 37 udp and tcp. glenn@LinuxBox:~$ sudo timedatectl set-ntp on
How to make the time synchronize?

Code:
glenn@LinuxBox:~$ timedatectl
               Local time: Sun 2022-04-03 05:50:21 PDT     
           Universal time: Sun 2022-04-03 12:50:21 UTC     
                 RTC time: Sun 2022-04-03 12:50:22         
                Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: no                              
              NTP service: active                          
          RTC in local TZ: no
Thanks in advance.
--glenn

Last edited by PsychoHermit; 04-03-2022 at 03:07 PM.
 
Old 04-03-2022, 04:27 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
There are several ways to synchronize time. I believe that Ubuntu uses systemd-timesyncd as its default time client which does not appear to be active. Check its status via the command:

sudo systemctl status systemd-timesyncd
 
Old 04-03-2022, 04:28 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,685

Rep: Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715
After you have a NTP client running, you need to configure NTP to address NTPD servers!
To get a FAST sync, there is a command line to quickly sync it up, but the ntp client must not be running at the time. So check the man page and verify the command.
Start with the man page for systemd-timedated.service and you cannot go wrong.

(This was all a LOT easier before systemd, but it is still doable. Let us know if you get stuck.)

If it is running, stop it. run the sync command, then start the service and it should keep your clock spot on forever.

Last edited by wpeckham; 04-03-2022 at 04:29 PM.
 
Old 04-03-2022, 04:40 PM   #4
PsychoHermit
Member
 
Registered: Aug 2021
Location: Carson City Nevada
Distribution: Debian Testing
Posts: 137

Original Poster
Rep: Reputation: Disabled
[code]
glenn@LinuxBox:~$ sudo systemctl status systemd-timesyncd
[sudo] password for glenn:
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; ve>
Active: active (running) since Sun 2022-04-03 03:58:42 PDT; 3h 36min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 4991 (systemd-timesyn)
Status: "Idle."
Tasks: 2 (limit: 6087)
Memory: 1.3M
CGroup: /system.slice/systemd-timesyncd.service
└─4991 /lib/systemd/systemd-timesyncd

Apr 03 03:58:42 LinuxBox systemd[1]: Starting Network Time Synchronization...
Apr 03 03:58:42 LinuxBox systemd[1]: Started Network Time Synchronization.
glenn@LinuxBox:~$ man systemd.timedated.service
No manual entry for systemd.timedated.service
[code]

Still not synchronized.

Thanks,
--glenn
 
Old 04-03-2022, 04:44 PM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,685

Rep: Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715Reputation: 2715
Quote:
Originally Posted by PsychoHermit View Post
glenn@LinuxBox:~$ man systemd.timedated.service
No manual entry for systemd.timedated.service

Try
Code:
man systemd-timedated.service
"-" <> "."
 
Old 04-03-2022, 05:16 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
I would of expected an initial time sync message in the status that syncs to ntp.ubuntu.com

Post the contents of your /etc/systemd/timesyncd.conf file.
Are you using a VPN service?
 
Old 04-03-2022, 06:42 PM   #7
PsychoHermit
Member
 
Registered: Aug 2021
Location: Carson City Nevada
Distribution: Debian Testing
Posts: 137

Original Poster
Rep: Reputation: Disabled
Newbie here finding the man pages less than helpful. I don't have a clue.

Code:
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.

[Time]
#NTP=
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
Thanks,
-glenn

Last edited by PsychoHermit; 04-03-2022 at 06:44 PM.
 
Old 04-03-2022, 06:52 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
The default settings I guess are compiled into systemd. I would try uncommenting RootDistanceMaxSec and change it from 5 to 10 seconds and see what happens. And restart systemd-timesyncd

Last edited by michaelk; 04-03-2022 at 06:54 PM.
 
Old 04-03-2022, 08:49 PM   #9
PsychoHermit
Member
 
Registered: Aug 2021
Location: Carson City Nevada
Distribution: Debian Testing
Posts: 137

Original Poster
Rep: Reputation: Disabled
Set RootDistanceMaxSec to 10 and restarted systemd-timesyncd.

Code:
glenn@LinuxBox:~$ timedatectl
               Local time: Sun 2022-04-03 11:48:05 PDT     
           Universal time: Sun 2022-04-03 18:48:05 UTC     
                 RTC time: Sun 2022-04-03 18:48:05         
                Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: no                              
              NTP service: active                          
          RTC in local TZ: no
Thanks,
--glenn
 
Old 04-03-2022, 09:24 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,750

Rep: Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929Reputation: 5929
Check the status to see if it connected to a time server

It appears that your hardware clock is set for local time but your system thinks its UTC (RTC in local TZ: no).

Last edited by michaelk; 04-03-2022 at 10:08 PM.
 
Old 04-04-2022, 08:47 AM   #11
PsychoHermit
Member
 
Registered: Aug 2021
Location: Carson City Nevada
Distribution: Debian Testing
Posts: 137

Original Poster
Rep: Reputation: Disabled
I switched to chrony and it hooked right up and synchronized.

Thanks for the help,
--glenn
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change MariaDb time, synchronize it with the server time (CentOS7)? AdultFoundry Linux - Newbie 1 01-09-2016 03:44 PM
[SOLVED] How do I synchronize VM guest time with host time PeterSteele Red Hat 3 09-26-2014 12:08 PM
Synchronize time kenneho Debian 11 01-21-2006 05:08 AM
synchronize time between linux and XP server taiwf Linux - General 1 11-03-2005 09:52 PM
synchronize linux domain time to workstation sunnyee Linux - Newbie 2 06-25-2004 04:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 07:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration