Wrong Date and time

Re: Wrong Date and time

Postby myo38 » Sun Oct 30, 2022 1:14 pm

Jocko,

Sorry, I typed -AS instead of -A5 !

Here is the good result :
Code: Select all
# grep '<ntp>' /etc/nas_conf_db.xml -A5
                <ntp>
                        <enable>true</enable>
                        <ip1>ntp.midway.ovh</ip1>
                        <ip2>ntp.unice.fr</ip2>
                        <server>true</server>
                </ntp>


Michel
myo38
Donator VIP
Donator VIP
 
Posts: 34
Joined: Thu Jun 30, 2022 6:49 am
Location: France - Tours

Re: Wrong Date and time

Postby Jocko » Mon Nov 07, 2022 11:06 am

Hi

So all seems ok :scratch

Then we try now to start (restart manually the service) :
Code: Select all
ps axf|grep ntpd
killall ntpd
ps axf|grep ntpd
php -f /direct-usb/fvdw/cron-boot/restart-sync-ntp-daemon.php
Here the script will wait at least 90'' (if you did not change the sleep value). And when the script is completed, do again
Code: Select all
ps axf|grep ntpd
Jocko
Site Admin - expert
 
Posts: 11558
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: Wrong Date and time

Postby myo38 » Mon Nov 07, 2022 4:52 pm

Hi Jocko,

I did what you said. Here is the script :

root@Serveur-Maison:/ # ps axf|grep ntpd
2125 pts/0 D+ 0:00 \_ grep ntpd
1456 ? Ss 0:00 /bin/ntpd -l
1622 ? Ss 0:00 /bin/ntpd -p ntp.midway.ovh -p ntp.ensma.fr
root@Serveur-Maison:/ # killall ntpd
root@Serveur-Maison:/ # ps axf|grep ntpd
2134 pts/0 R+ 0:00 \_ grep ntpd
root@Serveur-Maison:/ # php -f /direct-usb/fvdw/cron-boot/restart-sync-ntp-daemon.php
root@Serveur-Maison:/ # ps afx|grep ntpd
2173 pts/0 S+ 0:00 \_ grep ntpd
2147 ? Ss 0:00 /bin/ntpd -p ntp.midway.ovh -p ntp.ensma.fr
root@Serveur-Maison:/ #

I hope it helps.

I just have to add that once a while my server gets the good date and time. I don't know if it's due to the script (I've put a 300 sleep) or just that the restart of the fiber box is quick enough.

Michel.
myo38
Donator VIP
Donator VIP
 
Posts: 34
Joined: Thu Jun 30, 2022 6:49 am
Location: France - Tours

Re: Wrong Date and time

Postby Jocko » Mon Nov 07, 2022 8:58 pm

Hi

So no issue with thé script! But...
I just have to add that once a while my server gets the good date and time. I don't know if it's due to the script (I've put a 300 sleep) or just that the restart of the fiber box is quick enough.
I think there is an issue with the current max running Time value which aborts the script if you use this sleep value. I go to check what is thé current value.
Jocko
Site Admin - expert
 
Posts: 11558
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: Wrong Date and time

Postby Jocko » Tue Nov 08, 2022 9:48 am

Hi

Nope it is not the issue...
The firmware uses 60" as max execution time
PhpMaxRunTime.jpg
So the script should abort every time... And indeed when running PHP from a command line (it is your case) the default setting is 0 (so disabled). Then no issue on this side.

However to confirm this point you may edit the script restart-sync-ntp-daemon.php :
Code: Select all
<?php
require_once("/etc/inc/global_defs.inc");
require_once(
"/etc/inc/globals.inc");
require_once(
"/etc/finc/logError.finc");
require_once(
"/etc/finc/configfunc_read.finc");
require_once(
"/etc/finc/ntpfunc_daemon_ntp_kill.finc");
require_once(
"/etc/finc/ntpfunc_daemon_start.finc");

#Reset running configuration
set_time_limit(0);

$config = "";
$volatileConfig = "";

if (($rc= configfunc_read($config, $volatileConfig)) != OK_E){
    logError(__FILE__,  __LINE__ , "nasapi: Error reading conf files. err num = {$rc}", LOG_WARNING);
    return $rc;
}

# kill all orphan daemon
ntpfunc_daemon_ntp_kill();

$config['system']['ntp']['enable'] = "true";

# Custom a delay in seconds before starting ntp daemon
sleep(300);

$rc =  ntpfunc_daemon_start();

if ($rc != OK_E){
    logError(__FILE__, __LINE__ , "ntpfunc_ntp_start, err= {$rc}", LOG_WARNING);
    return FAIL_E;
}

return OK_E;

?>
So I believe 300" (5min) may be not enough. Sometime a box may take a long time to be synchronized. then you can increase again the sleep value.
You do not have the required permissions to view the files attached to this post.
Jocko
Site Admin - expert
 
Posts: 11558
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: Wrong Date and time

Postby myo38 » Mon Nov 14, 2022 2:59 pm

Jocko,

Thanks again for your help.

I did edit the script. And I have been happy : it worked the first day.
But then it seems to be working once every other day ! And now no more.

Probably that the fiber box started quickly enough to allow access to web time servers once a while.

I'm really disappointed !

What could be done ?

Michel.
myo38
Donator VIP
Donator VIP
 
Posts: 34
Joined: Thu Jun 30, 2022 6:49 am
Location: France - Tours

Re: Wrong Date and time

Postby Jocko » Tue Nov 15, 2022 10:42 am

Hi

:thinking

Can you post a screen capture of "Boot jobs" menu and attach your current version of restart-sync-ntp-daemon.php
Jocko
Site Admin - expert
 
Posts: 11558
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: Wrong Date and time

Postby myo38 » Tue Nov 15, 2022 1:50 pm

Jocko,

No problem, with pleasure !

Thanks again,
Michel
You do not have the required permissions to view the files attached to this post.
myo38
Donator VIP
Donator VIP
 
Posts: 34
Joined: Thu Jun 30, 2022 6:49 am
Location: France - Tours

Re: Wrong Date and time

Postby Jocko » Wed Nov 16, 2022 10:28 am

Hi,

all still seems ok :scratch
Note: I would have prefer you post the file and not a capture when you edit it

Anyhow we go to make a manual test... for a first test set a sleep value 5" instead of 300
So do
Code: Select all
 ps axf |grep ntpd| grep -v 'grep'
date
killall ntpd
date -s 2019.01.01-12:00
date
debugon
php -f /direct-usb/fvdw/cron-boot/restart-sync-ntp-daemon.php
debugoff
cat /var/log/messages
ps axf |grep ntpd| grep -v 'grep'
(wait around 1min or repeat date command up to date is updated)
date
Jocko
Site Admin - expert
 
Posts: 11558
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: Wrong Date and time

Postby myo38 » Wed Nov 16, 2022 2:34 pm

Hi,

Sorry, but neither a .php or a .txt or a capture file had been accepted. So I did how I could.

Here is the trace of the test you asked me :
# ps axf |grep ntpd| grep -v 'grep'
1456 ? Ss 0:00 /bin/ntpd -l
root@Serveur-Maison:/ # date
Mon Jan 1 21:22:52 CET 2018
root@Serveur-Maison:/ # killall ntpd
root@Serveur-Maison:/ # date -s 2019.01.014-12:00
Mon Jan 14 12:00:00 CET 2019
root@Serveur-Maison:/ # date
Mon Jan 14 12:00:05 CET 2019
root@Serveur-Maison:/ # debugon
root@Serveur-Maison:/ # php -f /direct-usb/fvdw/cron-boot/restart-sync-ntp-daemon.php
root@Serveur-Maison:/ # date
Wed Nov 16 15:26:50 CET 2022
root@Serveur-Maison:/ # debugoff
root@Serveur-Maison:/ # cat /var/log/messages
Jan 14 12:00:14 Serveur-Maison syslog.info syslogd started: BusyBox v1.21.0
Jan 14 12:01:34 Serveur-Maison authpriv.notice sudo: root : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/ps -ef
Jan 14 12:01:39 Serveur-Maison authpriv.notice sudo: root : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/ntpd -p ntp.midway.ovh -p ntp.ensma.fr
Nov 16 15:27:02 Serveur-Maison syslog.info syslogd exiting
root@Serveur-Maison:/ # ps axf |grep ntpd| grep -v 'grep'
2054 ? Ss 0:00 /bin/ntpd -p ntp.midway.ovh -p ntp.ensma.fr
root@Serveur-Maison:/ # date
Wed Nov 16 15:28:03 CET 2022

So it seems that the .php cron is working well ! For tomorrow I'll reduce the wait time to 59 sec, and I'll do it twice. We'll see.

Michel.
myo38
Donator VIP
Donator VIP
 
Posts: 34
Joined: Thu Jun 30, 2022 6:49 am
Location: France - Tours

PreviousNext

Return to Lacie cloudbox (white casing)

Who is online

Users browsing this forum: No registered users and 11 guests