Setting time, wi-fi

Kernels & Hardware, configuring network, installing services

Setting time, wi-fi

Postby luiznetto » 2017-04-26 19:00

Hi all. I run Wheezy on a laptop with wi-fi. I notice there is always a difference between the time shown by my cell phone (12:40 pm now) and that shown by my system clock (12:55 pm now). When I boot my laptop, I'm not connected to the internet yet; I only get connected to the wi-fi network by the Gnome Network Manager after I log into my user account, so it's impossible for my system to get the right time during boot (I think tzdata is the package responsible for this). Any way I can set up automatic time correction after boot and log-in?

Thanks a lot in advance.
luiznetto
 
Posts: 39
Joined: 2013-11-26 18:40

Re: Setting time, wi-fi

Postby phenest » 2017-04-26 20:23

Are you saying that the time never gets corrected? I think you need the ntpdate package.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Setting time, wi-fi

Postby cronoik » 2017-04-26 20:28

Please run:
Code: Select all
timedatectl

and check if 'NTP enabled' is set to yes. If not, uncomment the servers in vim /etc/systemd/timesyncd.conf and run the following commands:
Code: Select all
systemctl enable systemd-timesyncd.service && systemctl start systemd-timesyncd.service
Have a nice day!
cronoik
 
Posts: 205
Joined: 2015-05-20 21:17

Re: Setting time, wi-fi

Postby luiznetto » 2017-04-29 18:41

Hi guys

I did the following (I don't know if I did it right):
I installed ntpdate
Then I edited the file /etc/default/ntpdate:
Code: Select all
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.

# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
NTPDATE_USE_NTP_CONF=yes

# List of NTP servers to use  (Separate multiple servers with spaces.)
# Not used if NTPDATE_USE_NTP_CONF is yes.
NTPSERVERS="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org"

# Additional options to pass to ntpdate
NTPOPTIONS=""


I removed the ' yes ' on line 6

Now I think I can expect the time to be automatically updated each time I reconnect to the wireless (or cable internet) surface. Am I right?
luiznetto
 
Posts: 39
Joined: 2013-11-26 18:40

Re: Setting time, wi-fi

Postby phenest » 2017-04-29 18:59

You didn't need to edit the file. Open Gnome Settings > Date & Time. It's all there.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Setting time, wi-fi

Postby stevepusser » 2017-04-29 21:37

cronoik wrote:Please run:
Code: Select all
timedatectl

and check if 'NTP enabled' is set to yes. If not, uncomment the servers in vim /etc/systemd/timesyncd.conf and run the following commands:
Code: Select all
systemctl enable systemd-timesyncd.service && systemctl start systemd-timesyncd.service


It's a Wheezy system...advice for systemd is very unlikely to be of help.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.0.6, Pale Moon 27.4.0, Liquorix kernel 4.11-9, mpv 0.25.0, Kodi 17.3, Ksnip 1.3.1, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8410
Joined: 2009-10-06 05:53

Re: Setting time, wi-fi

Postby sjukfan » 2017-04-30 03:12

A pretty cheap version would be to use rdate and put this in cron
Code: Select all
@reboot sleep 120 && rdate some.ntp.server.netrdate -nca 0.se.pool.ntp.org
Buster amd64, Core 2 Quad Q9550
Stretch amd64, Core 2 Quad Q9400
Sid ppc, PowerPC 7447a
Sid ppc64, PowerPC 970FX
User avatar
sjukfan
 
Posts: 365
Joined: 2010-03-01 19:39

Re: Setting time, wi-fi

Postby luiznetto » 2017-05-02 14:57

It seems to be working! Thanks a lot, guys! I think we can mark this thread as solved. :)
luiznetto
 
Posts: 39
Joined: 2013-11-26 18:40

Re: Setting time, wi-fi

Postby phenest » 2017-05-02 15:46

Given the various solutions provided, could you tell us what you did to make it work. Just so others reading this may benefit.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Setting time, wi-fi

Postby luiznetto » 2017-05-04 14:09

phenest wrote:Given the various solutions provided, could you tell us what you did to make it work. Just so others reading this may benefit.

With pleasure. I only did what I said in my post above: I installed ntpdate, and then I edited /etc/default/ntpdate. And that was all!
cronoik suggested that I run
Code: Select all
timedatectl
but unfortunately I don't have this command in my system. What package does it belong to?
phenest suggested I run Gnome Settings, but I don't have Gnome either, or KDE, I prefer the much lighter and faster LXDE. I use some Gnome and KDE packages, but not the whole system.
There is often more than one solution to a Linux problem, and not everybody likes to edit system files, but I do what works for me.
It was a pleasure to interact with you guys, have a nice day! :)
luiznetto
 
Posts: 39
Joined: 2013-11-26 18:40

Re: Setting time, wi-fi

Postby GarryRicketson » 2017-05-04 15:13

Debian 7 wheezy does not have that command , there apparrentlty is a package in wheezy backports, but it is more of a systemd thing, I don't have it either,..but I am running Debian 7,.... in the later versions, like 7.11 it might be useable,
https://manpages.debian.org/jessie/systemd/timedatectl.1.en.html
I wouldn't want to put that on my Debian Wheezy,...but it's your system.
Code: Select all
garry@debian:~$ timedatectl
bash: timedatectl: command not found
garry@debian:~$ man timedatectl
No manual entry for timedatectl
.garry@debian:~$ lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:   Debian GNU/Linux 7.0 (wheezy)
Release:   7.0
Codename:   wheezy
#I just use the 'date' command to set my time, etc.
garry@debian:~$ date
Thu May  4 11:01:31 CDT 2017
garry@debian:~$ man date
 


---------- edited---------

I just noticed :
http://forums.debian.net/viewtopic.php?f=5&t=132877&p=643204#p642814Postby stevepusser » 2017-04-29 15:37>
It's a Wheezy system...advice for systemd is very unlikely to be of help.

I did not notice at first, but I see Steve all ready pointed this out.
User avatar
GarryRicketson
 
Posts: 4058
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Setting time, wi-fi

Postby phenest » 2017-05-04 17:00

luiznetto wrote:phenest suggested I run Gnome Settings, but I don't have Gnome

Sorry. I saw you were using Gnome Network Manager and assumed.
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Setting time, wi-fi

Postby luiznetto » 2017-05-10 18:10

Does anyone know if there is a Linux command that shows exactly what the BIOS clock shows without having to look at the BIOS? hwclock won't do this for me; besides the fact that it can only be run by root, it gives almost the same output as the date command:

Code: Select all
root@debian-luiz-computer:/home/luiz# hwclock -r
Wed 10 May 2017 11:52:19 AM PDT  -0.625363 seconds
root@debian-luiz-computer:/home/luiz# hwclock --show
Wed 10 May 2017 11:52:29 AM PDT  -0.062860 seconds
root@debian-luiz-computer:/home/luiz# su luiz
luiz@debian-luiz-computer:~$ date
Wed May 10 11:52:39 PDT 2017

I was pretty sure there was a command that did just that that I used a long time ago, but now I can't remember. I've been googling in vain. Can anybody help me? :?:
luiznetto
 
Posts: 39
Joined: 2013-11-26 18:40

Re: Setting time, wi-fi

Postby GarryRicketson » 2017-05-10 18:49

I've been googling in vain.

Really ?

Linux command that shows exactly what the BIOS clock shows
First hit:
http://www.thegeekstuff.com/2013/08/hwclock-examples/?utm_source=tuicool
1. Display Hardware Clock Date and Time

Just type hwclock, which will display the date and time of your system’s hardware clock. This is the same date and time that you’ll see from the BIOS screen. You can also use option -r, or –show to display the date and time.
User avatar
GarryRicketson
 
Posts: 4058
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Setting time, wi-fi

Postby Dai_trying » 2017-05-10 18:57

If you have your hardware clock set to UTC you can just date -u
Dai_trying
 
Posts: 287
Joined: 2016-01-07 12:25

Next

Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable