WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: getTime.sh not working at startup  (Read 2878 times)

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 759
Re: getTime.sh not working at startup
« Reply #15 on: May 04, 2025, 06:46:12 AM »
Some doc's in TC doesn't have being updated for long time.
I see in the wiki it has:

https://wiki.tinycorelinux.net/doku.php?id=wiki:boot_options#deprecated_boot_options
« Last Edit: May 04, 2025, 06:53:01 AM by patrikg »

Offline Stefann

  • Wiki Author
  • Full Member
  • *****
  • Posts: 104
Re: getTime.sh not working at startup
« Reply #16 on: May 04, 2025, 12:18:33 PM »
Note, I am very well aware tiny core is run by volunteers, and with great respect I very much like the project.
It's a bit too much for me to volunteer as maintainer, but I took the time to minutely report my findings especially with the intend to help others.

With that said:
I feel current wiki text is not correct, this text (and more information I did find on this forum before posting) brought me to start this topic with title "geTime.sh not working at startup".

current wiki on nortc bootcode says: "Set UTC time at boot, internet required"
This is not correct: the nortc bootcode will NOT set UTC if rtc is present, it only does that if no functional rtc is present.
Suggestion: "use if no rtc (real time clock) present, to set UTC time at boot without functional rtc"


Alternatively change settime.sh to comply with current wiki text (not tested suggestion to initialize to unrealistic value to force internet sync):
code snippet:
Code: [Select]
................
do
    [ $((CNT++)) -gt 60 ] && break || sleep 1
done


if [ $CNT -le 60 ]
then
    CNT=9999
    NRT=0

#suggested addition (not tested)
#force system clock to unrealistic value to trigger waiting for successful internet sync
    sudo date 010101012010

    while sleep 0
    do
        XXX=$(/bin/date -I)
        XXX=${XXX:0:4}
       
# this comparison breaks out with functional rtc without the above suggested addition
        if [ "$XXX" -ge "2015" ];
        then
            break
        fi

..........

Note:
personally I would change the wiki, not settime.sh because the sync adds boottime which I donot want to spend if I have a functional rtc.
However... I think it makes sense to add a bootcode like "ntpd" that enforces "sudo ntpd -p pool.ntp.org". This does not only sync systemtime but also syncs the rtc to have a "good start from rtc" at next boot. I will now do that in bootlocal.sh but as ntpd is already in the package starting ntpd with a standard bootcode would be nice

So.... I kind of hope some maintainer can fix the wiki. and maybe copy ntpd bootcode suggestion in TC17.
And if not: it will help those struggling with the issue and search the forum.
« Last Edit: May 04, 2025, 12:30:32 PM by Stefann »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15204
Re: getTime.sh not working at startup
« Reply #17 on: May 04, 2025, 01:44:59 PM »
You should be able to edit the wiki yourself?

Offline Stefann

  • Wiki Author
  • Full Member
  • *****
  • Posts: 104
Re: getTime.sh not working at startup
« Reply #18 on: May 04, 2025, 02:03:40 PM »
I think I cannot > just checked the page and don't think I have editing rights.

If I click "page source" I get: "This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong."

note: I have never in my lifetime edited a wiki page so I may do something wrong

(also: can I just "do" that? not stepping on toes?)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12153
Re: getTime.sh not working at startup
« Reply #19 on: May 04, 2025, 04:09:02 PM »
Hi Stefann
I think I cannot ...
Now you can. :)

Offline Stefann

  • Wiki Author
  • Full Member
  • *****
  • Posts: 104
Re: getTime.sh not working at startup
« Reply #20 on: May 05, 2025, 09:30:14 AM »
@Rich: thanks

wiki updated: "Use if no rtc (real time clock) present, to set UTC time at boot without functional rtc, Internet required."

To double check, I tested at both my systems:
- HP510 thin client with VIA Eden x86 processor, 1GHz, 2core, 64bit running on TC16/32bit
- other thin client with VIA Eden x86 processor, 500MHz, 1core running on TC15/32bit
in both cases:
- used nortc bootcode
- modified settime.sh to include logging and added it to .fieltool.lst
- gave date a 5minute offset, synced to hwclock, checked.
- reboot
- logging confirmed settime.sh was called and conditions to sync with internet were met
- but 1st "date" call reported "2025" and getTime.sh call was skipped as result of <2015 check
>> so indeed no internet time sync

It's a bit strange, also found below code snippet in tc-config.
- This basically "does not set system clock" in case of nortc bootcode.
- This means that 1st date call in settime.sh is towards uninitialised system clock
>>>I guess system clock "auto initialises" towards hwclock.
- Maybe not at all processors, maybe just my VIA Eden processors
- Modified wiki text makes clear to only use nortc without hw clock. in case of hwclock present it keeps the behaviour "undefined" which is probably correct. One could dig in deeper but I guess this gives enough warning to trigger a potential someone having a problem in future.

And in case one has a hwclock:
- better not use nortc bootcode
- without internet keep running from hwclock
- with internet add "sudo ntpd -p pool.ntp.org" to filetool.sh to keep syncing system clock and hwclock to "real time"

Code: [Select]
if [ -n "$NORTC" ]; then
echo "${BLUE}Skipping rtc as requested from the boot command line.${NORMAL}"
else
while [ ! -e /dev/rtc0 ]; do usleep 50000; done
if [ -n "$NOUTC" ]; then
/sbin/hwclock -l -s &
else
/sbin/hwclock -u -s &
fi
fi