Tiny Core Linux
Tiny Core Base => TCB Tips & Tricks => Topic started by: ferran on March 23, 2020, 03:18:45 AM
-
Hello / Hi everybody:
If your TC clock is broken usually because the hardware clock's battery is dead (like to me), I suggest you to use this command
ntpd -q -p (here the pool.ntp.org server)
NOTE: You must be connected to internet
Before let's take a look to ntp servers in its web:
https://support.ntp.org/bin/view/Servers/NTPPoolServers (https://support.ntp.org/bin/view/Servers/NTPPoolServers)
Search the most fine hostname time zone browsing first by continent and after by your nation state or country. In my case i found 0.es.pool.ntp.org, so
ntpd -q -p 0.es.pool.ntp.org
Suddenly my desktop clock changed the time!. I hope it works to you as fine as to me.
-
Hi, ferran!
Great trick! The right time for the running system is one of the cornerstones. Not trying to underscore Your efforts I propose to look at /usr/bin/getTime.sh script. In general there are a lot of interesting things inside TinyCore. And there is wiki on the project site, worth digging into.
Regards!
-
Thanks! :)
I saw this script but not works to me (surely because it imports from /etc/sysconfig/ntpserver the generic server "pool.ntp.org". It lefts to be more specific with the time-zone)
-
Hi, ferran!
Interesting that ntpd doesn't work for You with pool.ntp.org. They must find appropriate local time server with the help of DNS. Such fail means, that for some reason they can't find You correctly. Does getTime.sh fails always, or sometimes it sets the time? Maybe try to play with /etc/ntpd.conf? I mean the proposed content
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
I never had problems with time setting, so I can not check this issue and help You with testing. Probably to emulate such problems i will need to brake my DNS.
-
Very good !. In this moments i can't to test it, but i will tell you something very soon.
-
jazzbiker:
Well, in my TC CorePlus 11.0 version I haven't /etc/ntpd.conf, I've /etc/sysconfig/ntpserver.
All this theme is a bit more difficult it seems (for me) and for this reason I decided to change the time directly with a single command.
Robert Shingledecker first and Bela Marcus after made the /etc/init.d/settime.sh:
#!/bin/sh
# (c) Robert Shingledecker 2012
# Bela Markus 2015
# Wait for network to come up and then set time
CNT=0
until ifconfig | grep -q Bcast
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
if [ $CNT -le 60 ]
then
CNT=9999
NRT=0
while sleep 0
do
XXX=$(/bin/date -I)
XXX=${XXX:0:4}
if [ "$XXX" -ge "2015" ];
then
break
fi
if [ $CNT -gt 10 ];
then
/usr/bin/getTime.sh
if [ $NRT -gt 5 ];
then
break
fi
CNT=0
NRT=$((NRT+1))
fi
CNT=$((CNT+1))
sleep 1
done
fi
I changed the line if [ "$XXX" -ge "2015" ]; with if [ "$XXX" -ge "2021" ];
Now looks that it forks to another script named /usr/bin/getTime.sh . With the above correction If the year is less than "2021" the script forks to the getTime.sh (made by Bela Markus too) is:
#!/bin/busybox ash
# bmarkus - 26/02/2014
NTPSERVER=$(cat /etc/sysconfig/ntpserver)
/usr/sbin/ntpd -q -p $NTPSERVER
Finally It forks (again) to an another script named /etc/sysconfig/ntpserver which It contents only this:
pool.ntp.org
I changed with your suggestion (but for Spain) with:
server 0.es.pool.ntp.org
server 1.es.pool.ntp.org
server 2.es.pool.ntp.org
server 3.es.pool.ntp.org
I don't know If now works (because my clock was changed before). Surely yes... Tomorrow we'll know it :)
-
Hi, ferran!
I think You don't need to change settime.sh. This part of it comparing year with 2015 is only for early Raspberries, which had no RTC at all, as far as i know. So leave settime.sh unchanged.
Now about /etc/ntp.conf and /etc/sysconfig/ntpserver. Really, TinyCore have no /etc/ntp.conf. The only ntp server name is stored in /etc/sysconfig/ntpserver text file and is used by getTime.sh script. But in order to make various servers acceptable by ntpd I proposed to create /etc/ntp.conf and write into it
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
as ntp.org recommend. And then call
sudo ntpd -q
without naming certain server with the help of -p switch and allow ntpd to choose server from /etc/ntp.conf
Maybe other TinyCore users face the same problems with time determining? If You will find the way to solve problem not only for Spain it can be usefull for others too.
I still don't understand why ntp.org can not locate You on our planet correctly. That is why i proposed to continue experiments with original getTime.sh ( before creating /etc/ntp.conf ).
For example: You boot Your box and have wrong time on it. The You bring up the network and
sudo getTime.sh
echo $?
date
maybe several times until time will be set correct. It seems to me that getTime.sh can not fail absolutely, because pool.ntp.org is choosing various ntp servers for every new call.
-
Ok, ok. Let me restore the files changed before like the original and after i will do you said.
-
By the way, if You are sure that Your RTC is dead You can use NORTC boot code.
-
Here I returned.
So I made the /etc/conf as you said. Also i wrote sudo ntpd -q, sudo getTime.sh and the echo says "0". Obviously the date its the same (I changed it when i connected before).
I don't understand why don't works too... luckily i'll have time to find out.
About NORTC i don't know what i must to do yet. I'll look into it further.
-
Hi, ferran!
What is /etc/conf? ntpd is looking for /etc/ntp.conf
You can read about boot codes in wiki or in FAQ.
I don't understand what's going on, and I can not do any testing, so let's take the things as they are. You have the working ntp servers, so anybody can repeat Your steps, if necessary.
-
Hi, ferran!
What is /etc/conf? ntpd is looking for /etc/ntp.conf
You can read about boot codes in wiki or in FAQ.
I don't understand what's going on, and I can not do any testing, so let's take the things as they are. You have the working ntp servers, so anybody can repeat Your steps, if necessary.
yes. I would say /etc/ntp.conf It was just a writing mistake.
Ok. It's a good moment that the people talks :)
-
Hi, ferran!
Some observations about ntpd.
Exit code with -q switch says nothing about sucess or fail:
tc@box:~$ sudo ntpd -q -p rubbish.box
tc@box:~$ echo $?
0
Some peer acessibility testing may be done with the help of -w switch:
tc@box:~$ sudo ntpd -w -p pool.ntp.org
ntpd: reply from 91.236.251.29: offset:+0.012651 delay:0.031612 status:0x24 strat:2 refid:0x15119582 rootdelay:0.026810 reach:0x01
ntpd: reply from 91.236.251.29: offset:+0.020740 delay:0.017485 status:0x24 strat:2 refid:0x15119582 rootdelay:0.026810 reach:0x03
^C
tc@box:~$ sudo ntpd -w -p 0.es.pool.ntp.org
ntpd: reply from 81.19.96.148: offset:+0.029865 delay:0.085033 status:0x24 strat:2 refid:0x4dcccb8c rootdelay:0.035935 reach:0x01
ntpd: reply from 81.19.96.148: offset:+0.030063 delay:0.087207 status:0x24 strat:2 refid:0x4dcccb8c rootdelay:0.035935 reach:0x03
^C
tc@box:~$ sudo ntpd -w -p rubbish.box
ntpd: bad address 'rubbish.box'
ntpd: bad address 'rubbish.box'
^C
Multiple servers can be used:
tc@box:~$ sudo ntpd -w -p rubbish.box -p pool.ntp.org
ntpd: bad address 'rubbish.box'
ntpd: reply from 79.142.192.130: offset:+0.019904 delay:0.002564 status:0x24 strat:3 refid:0x963937f8 rootdelay:0.009308 reach:0x01
ntpd: bad address 'rubbish.box'
ntpd: reply from 79.142.192.130: offset:+0.019750 delay:0.002560 status:0x24 strat:3 refid:0x963937f8 rootdelay:0.009308 reach:0x03
ntpd: reply from 79.142.192.130: offset:+0.019888 delay:0.002740 status:0x24 strat:3 refid:0x963937f8 rootdelay:0.009308 reach:0x07
^C
If You will be in the mood for experimenting, it will be interesting to see the results.
-
Yes. the last discovery i did was to aply the /etc/ntp.conf into the ntpd -w -q
sudo ntpd -w -q /etc/ntp.conf
It works successfully ! but the /etc/ntp.conf dissapear with each reboot or shutdown :'(
-
Hi ferran
You need to add:
etc/ntp.conf
to your /opt/.filetool.lst file and then run a backup. Note there is no leading slash in the path.
-
Rich done! I did
sudo echo "etc/ntp.conf" >> /opt/.filetool.lst
-
Hi ferran
You also need to run a backup. You can do that from the command line if you wish:
filetool.sh -b
-
Rich
Done. But before I added to ntp.conf three lines for security that i checked in this site:
https://www.garron.me/en/linux/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html (https://www.garron.me/en/linux/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html)
So i did
sudo echo "restrict defult noquery nopeer" >> /etc/ntp.conf
sudo echo "restrict 127.0.0.1" >> /etc/ntp.conf
sudo echo "restrict ::1" >> /etc/ntp.conf
-
Today is Twe Mar 24 11:35:19 UTC 2020 since I wrote
sudo
ntpd start
It's allright !
-
I will rescue this theme. Since my last TC crashes i forget several simple configurations, in this case with the date/time
I remember I had "sudo ntpd start" line into a file. In each restart i did (and once connected to internet) the clock updates automatically at current date/time.
What is the file that i need append the line "sudo ntpd start" ?
-
Hi ferran
If you are running a GUI:
echo "sudo ntpd start" > ~/.X.d/StartNTP
If you are running in text mode:
echo "sudo ntpd start" >> ~/.profile
-
Thank you again Rich. I'm sure that it will work when i restart the computer.
-
Actually, what the extension needs is a startup script in/usr/local/etc/init.d/. Even without it you should still be starting it as a system daemon in /opt/bootlocal.sh. The userspace login scripts are not intended to be the place to start system background processes that run listeners on restricted ports meant for use by everyone logged into (or who can connect to) the system.
-
In my humble opinion (I've only been in TC 1 month) what has shocked me most about TC is that we don't have a configuration wizard (as in any other linux distribution) to detect your hardware and install everything you need to have a time zone, a clock server (if you don't have a clock battery in your PC) or the ALSA or if you want the Xvesa or the Xorg, if you have Nvidia, printers, usb, etc.etc.
Well... this is another history.
-
Maybe because you haven't written it yet? Not every distro has been around two decades and has scores of contributors. Sadly, this forum gets WAY more requests than offers.
-
Time to time ;D