https://skarnet.org/software/s6/notifywhenup.html
s6 supports that mechanism natively: when the service directory for the daemon contains a valid notification-fd file, the daemon's supervisor, i.e. the s6-supervise program, will properly catch the daemon's message, update the status file (supervise/status), then notify all the subscribers with a 'U' event, meaning that the service is now up and ready.
https://skarnet.org/software/s6/servicedir.html
An optional regular file named notification-fd. If such a file exists, it means that the service supports readiness notification. The file must only contain an unsigned integer, which is the number of the file descriptor that the service writes its readiness notification to. (For instance, it should be 1 if the daemon is s6-ipcserverd run with the -1 option.) When a service is started, or restarted, by s6-supervise, if this file exists and contains a valid descriptor number, s6-supervise will wait for the notification from the service and broadcast readiness, i.e. any s6-svwait -U, s6-svlisten1 -U or s6-svlisten -U processes will be triggered.
The file /run/66/scandir/0/ntpd/notification-fd doesn't exist and when ntpd goes up or down throws an error (not fatal),
If you create such a file empty, with # in it, or anything else it throws a fatal error. If you put a "1" only in that file and save it, ntpd starts and stops with no errors or warnings. If I try a 0 it starts but with a delay. -1 throws a fatal error.
Should ntpd-66serv be creating this file with a value of 1? I am not very clear on ipcserver yet.
moved this topic here because it's not a bug but a misunderstood from your part :)
so readiness notification only works if the daemon provide the feature and it's not the case with ntpd. For example dbus-daemon have an options called --print-pid(refers to it man pages), this option allow to write a the given file descriptors(e.g 3), in this case you can use @ notify = 3 to specify s6-supervise to read the fd (file descriptor) and wait for an event. When the daemon is ready, dbus-daemon will write the fd and so s6-supervise know that the daemon is really ready.

Now the @ notify (aka notification-fd) can only contain an unsigned int (positive integer value ). By default on linux system the fd 0 is used for stdin(standard input), fd 1 is used for stdout(standard output) and fd 2 is used for stderr(standard error). So the first fd available should be 3, that's why , in the majority of the case, you will see @ notify = 3.

hope it's a little more clear
Now I understand, I was just trying to investigate the cause of the warning:
66-start: info: Already up: ntpd-log
66-start: warning: /run/66/scandir/0/ntpd/notification-fd is not present - ignoring request for readiness notification
66-start: info: Started successfully: ntpd
66-stop: warning: /run/66/scandir/0/ntpd/notification-fd is not present - ignoring request for readiness notification
66-stop: info: Stopped successfully: ntpd
the reason is:
if you start a service with 66-start or 66-all by default the API will use -U. With this option the API expect to find a notification-fd at the service directory. If the notification-fd is not found the API will change automatically the -U by -u option and warm the user about the change. I realized that behaviour can confuse users and i will make a few changes about this on the next 66 release.
So, this is just a warning and it can be ignored safely.
The reason I am paying attention is trying to find out why ntp is not working right, or what in the system is throwing it off. When I boot I get a classic 3hr off real time. ntpd is running, tz is set correctly, I stop the service and start it again and the time is corrected to 0.03s+/- An hour or two later I test against an internet service and it is 1.5s away. That is too much for a running ntpd. I stop and restart .... the error goes away. If I do this reset and leave ntpd off afterwards the time stays pretty close to the servers, it is when ntp is running that it is slips gradually.

I think this may be irrelevant to 66 and more internal to the system and ntp. Switching back and forth from hw: localtime/UTC in 66.conf has little effect on this craziness.
hum, maybe something it can be interesting to test (never tried), skarnet implement it own ntp client:
https://github.com/skarnet/s6-rc/blob/master/examples/source/ntpclient/run
somethings may need to be changed like the server address...
it easy to convert it to 66 frontend, just remove the shebang and the fdmove -c 2 1 line and copy the rest into your key @ execute value and declarate it as classic service(no dependencies is needed).
Tell us if you get something relevant
I tried it but I don't really understand how to get it to work.
What is the shebang ? :)

Am I supposed to call this script something like /usr/local/bin/skar-ntp and make a service script for it with above details, and run it along ntpd? I couldn't even get it to run at all.
save this at /etc/66/sysadmin/service/my_ntpd
[main]
@ type=classic
@ name=my_ntpd
@ description="my ntpd daemon"
@ user=(root)
@ options=(log)

[start]
@ build=auto
@ execute=
(
	if
	{
		pipeline
		{
			s6-setuidgid ntp
			backtick -n NTPSERVERIP
			{
				pipeline { s6-dnsip4 -t 16000 0.fr.pool.ntp.org }
				s6-head -n 1
			}
			importas -u NTPSERVERIP NTPSERVERIP
			s6-sntpclock -v 2 $NTPSERVERIP
		}
		s6-clockadd -e 120000
	}
	s6-setuidgid nobody
	s6-sleep 14400
)
disable the ntpd daemon and enable this one

shebang: language interpreter -> # !/usr/bin/bash , # !/usr/bin/execlineb -P, # !/usr/bin/python, ...
this is the first line that you see in a scripts file
note:s6-dns need to be present on your system
It works! Thank you.

Shebang: I didn't know this specific meaning, in slang it seems it has different meaning, like the "whole", the "package".
No it doesn't
I don't know what I did yesterday, maybe time was set correctly by ntpd before disabling, but this is not affecting time at all. I can set the time minutes, hours, days off and it is not changing it, disabling re-enabling ... nothing. I switched server and the same. When I mess the time up, manually and re-enable ntpd then it works ... for now!

Sometimes the simplest little things can drive you off the wall. Just the fact you have to mess with such things for days it can drive you crazy.

What is funny is that I have a wall clock that works with a single AA battery. My friend won it in a ruffle at school 23 years ago. I used a new battery and set it and every 3-4 months it slips 1' ahead (not behind due to rust or dust and friction) and maybe at 15 months it needs a new battery. Freaking intel machine I have to wind like it is a cookoo!
  • [deleted]

@ fungalnet

Plz, update s6-networking and tell us if that work now. Thx

Edit: You can manually try like that for a test from your user:
s6-dnsip4 -t 16000 pool.ntp.org
In most cases it's best to use pool.ntp.org to find an NTP server (or 0.pool.ntp.org, 1.pool.ntp.org, etc if you need multiple server names). The system will try finding the closest available servers for you
that will output some address IP. Take one of them and execute
s6-sntpclock -v2 $ADDRESS_IP | s6-clockview
  • [deleted]

ntpclient-66serv service package is now available on Obarun 66service repo.
When I got those 4 IP I used the second command and 3 gave me the first error one gave me the second
s6-sntpclock: info: NTP round-trip 5/10 failed: Connection timed out
s6-sntpclock: fatal: unable to complete series of SNTP exchanges: Connection timed out
or
s6-sntpclock: fatal: time uncertainty too large
When I pinged those IPs and also pinged geo.local ntp servers the ping response on the local ones was 1/5 - 1/6 shorter.
Among the local ones only one passed the sntpclock test.

So something times out too soon and the ntp can't do its work.
s6-clockview doesn't make any difference whether used or not or have any output when run alone.
s6-sntpclock: fatal: time uncertainty too large
you need to force the update, i think...
try this one, make a file in /etc/66/sysadmin/service/ntpclient
[main]
@ type=classic
@ name=ntpclient
@ description="ntpclient daemon"
@ user=(root)
@ options=(log env)

[start]
@ build=auto
@ execute=
(
    if
    {
        pipeline
        {
            s6-setuidgid ntp
            backtick -n NTPSERVERIP
            {
                pipeline { s6-dnsip4 -t 16000 pool.ntp.org }
                s6-head -n 1
            }
            importas -u NTPSERVERIP NTPSERVERIP
            execl-cmdline -s { s6-sntpclock ${CMD_ARGS} -v2 $NTPSERVERIP }
        }
        execl-cmdline -s { s6-clockadd ${CMD_ARGS} }
    }
    s6-setuidgid nobody
    s6-sleep 14400
)

[environment]
!CMD_ARGS=-f
then 66-enable -f -S ntpclient
see what's happen. if all is good change the /etc/66/conf/ntpclient and replace the CMD_ARGS=-f by an empty one (meaning CMD_ARGS=), than 66-start -r ntpclient to reload the configuration file.
An option will come soon on 66-start to properly handle such a case when the configuration file is needed to be changed on the fly. Work like a charm on my machine but...
ntpclient runs alone, not together with ntpd, right?
on the pipeline, is it ok to change the pool.ntp.org with <country_code>.pool.ntp.org? It gives different results.
It worked though, without ntpd running, I bumped the clock up some hours and started it. Then I check with time.is

Should I leave the -f permanently?
no, the -f options is only needed when you have a big difference between your clock and the time coming from the server, so like i said you edit the file /etc/66/conf/nptclient as this
!CMD_ARGS=
yeah you should able to change your country side, and yes ntpd as nothing to do with ntpclient. so if you are satisfied you can remove the opennptd package and the associated service.
trick: you create an another variable in the [environment] section like this
!CMD_ARGS=
!COUNTRY=<my_country>.pool.ntp.org
and change this line in the service file declaration
pipeline { s6-dnsip4 -t 16000 ${COUNTRY} }
now you should be able to change your country like you want simply editing the /etc/66/conf/ntpclient and doing a 66-start -r ntpclient command :). This can be usefull if you want to test multiple country.
  • [deleted]

@ fungalnet
Should I leave the -f permanently?
Two days ago, during my test, I asked to skarnet, the author of the software why -f option is not set by default and I got this answer.
The assumption with these tools is that if you're getting crazy time (either because your clock has gone insane, or because the other source has gone insane) it's way better to fail and raise an alarm than it is to blindly work.
The exception is when your local clock has a totally unreliable value, such as devices without a battery, without CMOS, and that just booted - so they have no idea what date/time it is. In which case, to get a sensible starting point, you accept the first thing a NTP server tells you and that's what the -f option is for.
About the default value time defined for this option I got this answer
It's a reasonable one, because: clocks drift, it's common to see a drift of one second and what is the maximum value I should use, how to calculate this value but generally a call to a NTP client is made before they drift too much and it's very rare that a drift goes above 1 second so 2 seconds of accepted delta is not too big but is safe you just need to guesstimate it, but unless you have very specific circumstances I suggest you just go with the default.
Most networks are reliable enough that you'll get way under 1 second delta and most clocks are reliable enough that you won't drift more than 2 seconds between 2 calls to s6-sntpclient. My servers have a service that call s6-sntpclient something like once every 6 hours if you trust your system clock, you can make that once every 24 or 48 hours in any case that's rare enough not to cause any inconvenience to your network or to the NTP server, and often enough to catch any drift before it becomes too big
Thank you both, it is an interesting subject. I made all the changes mentioned above and ntpclient (the custom one, not the one from the repository) seems to work fine. For once after a long while I get accurate time. I used to set it by hand against time.is once a day but with ntpd-66 I thought I'd give it a try again. On 66.conf before tz it asks if hw clock is local or UTC. No matter what I used it would still be wrong, although I think the cmos is working fine, hw-clock is good. I'm not talking about 1-2" delta, I'm talking 2 or 3 hrs, like the tz was wrong. Then a couple of weeks while ntpd was on the clock slipped a couple of boots by 36hrs off. I guess a problem with ntp.org could have triggered it.

Now, what is the difference with service scripts in /etc/66/sysadmin/service and /etc/66/service ?
/etc/66/service is the default directory where pacman install the service file (so, packager directory), the /etc/66/sysadmin/service is a sysadmin directory and NEVER touched by pacman.
So, now you have a service that you want to change because the dev did a bad service file declaration (F@ # ^#{\ dev), make a copy of the service from /etc/66/service to /etc/66/sysadmin/service and work on this one. When the @ # ^{\ dev will realize his mistake he will update the package and pacman will overwrite the /etc/66/service file.
Well, in fact you never loose your own changes.
This behaviour is equal for an user, if you want to do some change on a given service make a copy from the original to /home/<user>/.66/service.

Now, when you enable a service with root privileges the first directory checked to find the service is /etc/66/sysadmin/service than if the service was not found it will search at /etc/66/service. So your service is always took before the original one.
This is the same for an user, the first directory checked is /home/<user>/.66/service than /etc/66/sysadmin/service than /etc/66/service. That's mean that a sysadmin can rectify a service which it will be available for all users on the machine ;).
So if you install foo-66serv it goes to service, if you copy and modify it in sysadmin/service/ and now there are two, 66 neglects the oem one and reads the custom, or do you have to remove the original?
I assume when the service has the same name the preference is for the sysadmin.

Powered by Obarun