You are not logged in.

#1 2014-01-06 23:43:11

browntown
Member
From: Salem, OR USA
Registered: 2012-11-20
Posts: 63

[Resolved] Wicd script for ntpd

Resolved edit: I just started/enabled ntpd.service (after adjusting the conf file to local servers and iblast per the wiki).  So far so good even with mixed connectivity.

Hi all, I use arch on my netbook that is not always connected to the internet.  I successfully use wicd scripts to power on dropbox when connected, and stop it when disconnected.

I'd like to use wicd in the same manner to query the time server only when connected. I figure the simplest way would be to issue a

ntpd -gq

in the postconnect script.  That way it ntp runs once, can adjust over 5 minutes, and quit once per online session. Figured because it quits by itself with the -q flag, no disconnect script would be needed.

I tacked the following onto my

 /etc/wicd/scripts/postconnect/dropbox 

dropbox script which has been made executable.

#!/usr/bin/env bash
su -c 'DISPLAY=:0 /usr/bin/dbus-launch dropboxd &' pumpkin #pumpkin is the username on this netbook
sudo /usr/bin/ntpd -g -q &	# sync software time over network once and close
sudo /usr/bin/hwclock -w & 	# sync software time to hardware to preserve across reboot


I'm not sure that it is working though,

a.) does the syntax look right? my scripting skills are non-existent.
b.) not sure if I need the sudo's or the &'s
c.) anyway to log this and see if it happened?
d.) when I try to play with the clock to get it to change, things get wonky.  I got it to work once, but the other time seemed to crash things (probably because I offset the time by hours instead of minutes)

Thanks in advance.

-josh

Last edited by browntown (2014-01-09 13:46:47)

Offline

#2 2014-01-07 00:16:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Resolved] Wicd script for ntpd

If you are doing this for the leaning experience, then please disregard this post.

I don't see the advantage of having ntpd work in this way.  Ntpd doesn't take very much bandwidth nor processing power to do its thing, and there are a number of things that can go awry if you don't have the system time correct.  You should especially not be syncing so sparsely as to potentially need to have your time adjusted by five minutes or more.

The ntpd service handles intermittent connectivity perfectly fine these days, so I am failing to see the advantage here.  If you are really just concerned by having it try to connect while you are not connected to the network, then maybe you should check out chrony.  Chrony is able to be started and stopped with network connectivity and there is a script to do this with NetworkManager available in the AUR.  Maybe you could take inspiration from that, or even check out the script from networkmanager-dispatcher-ntpd from the official repos to see how it starts and stops ntpd upon {,dis}connect.

Offline

#3 2014-01-07 05:15:02

browntown
Member
From: Salem, OR USA
Registered: 2012-11-20
Posts: 63

Re: [Resolved] Wicd script for ntpd

WonderWoofy wrote:

If you are doing this for the leaning experience, then please disregard this post.

Fair enough, thank you for your reply.

WonderWoofy wrote:

I don't see the advantage of having ntpd work in this way.  Ntpd doesn't take very much bandwidth nor processing power to do its thing, and there are a number of things that can go awry if you don't have the system time correct.  You should especially not be syncing so sparsely as to potentially need to have your time adjusted by five minutes or more.

OK, I guess the g flag can go, it has never been 5 minutes off, I used that flag when I was trying to test things.

WonderWoofy wrote:

The ntpd service handles intermittent connectivity perfectly fine these days...

I didn't know this, thank you.

WonderWoofy wrote:

maybe you should check out chrony.  Chrony is able to be started and stopped with network connectivity and there is a script to do this with NetworkManager available in the AUR.

I saw this in the wiki and was trying to replicate it with wicd without adding chrony or replacing wicd (which I prefer).

Thank you again for taking the time to answer my post. If ntpd is connection tolerant, should I just load the daemon and be done with it, or is this like you say just an academic solution?

Offline

#4 2014-01-07 05:35:25

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Resolved] Wicd script for ntpd

If you really want to seek out a solution and learn a bit more about how wicd handles these start/stop things, then I say go for it.  But it wouldn't really be gaining you any sort of advantage.  If it were me, I would just start/enable ntpd.service and be done with it.  Though you should probably set the timeservers in /etc/ntpd.conf to something as close to you as possible.  I have read that you should also append iburst to the server lines as well, though I honestly have no idea what that is actually for.

I tried chrony once, and it is apparently the default ntp daemon on fedora.  But I found it to be far too complex for my liking and promptly switched back to ntpd.  Interestingly,  have seen comments from some of the red hat employees who seem to say the same thing... and they are the ones putting fedora together.  Go figure.

Offline

Board footer

Powered by FluxBB