Seconds time difference btw php mysql in jail

Status
Not open for further replies.

King

Cadet
Joined
Feb 15, 2018
Messages
3
I am using as spider to index websites, but are having issues with time differences. The freeness server is running ntp servers and i have installed apache, php, mysql in a jail. The spider needs same time in mysql and php to execute, but php time and mysql in the same jail is always 5-10 seconds off (due to updates i can't change the scripts).

I would expect everything to run the time of the freenas server. Timezones are set to the same but are there any way to get the time to be the same in php/mysql in a jail?

Anyone?
 
Last edited:

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
Were you able to resolve this? If not, did you configure NTP within the jail using the instructions in https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-ntp.html?
This seems wrong to me (or at least very counter intuitive). Jails really maintain their own clock?

Reviewing @King's question once again, I don't even think this would help. This issue is that somehow MySQL's NOW() and PHP's time() are returning different values (within the same jail). And, honestly, I can't figure out how this would even be possible. Both of these functions are pulling from the system clock.

How have you diagnosed that the times are 5-10 seconds off?
 

King

Cadet
Joined
Feb 15, 2018
Messages
3
I had made a mistake in the NTP in the jail by putting the server name in the rc.conf file. This is corrected ad restarted but it doesn't change the issue.

I'm using a script called spider-plus which is a spider-server to index sites. I have looked at the code generating the issue:
1. it writes one line in a mysql table (same jail) using mysql NOW()
2. it retrieves that same line
3. it gets PHP time from: time() and format
4. it calculates the difference

It comes up with a difference of 5-10 sec. But i guess it might be slow execution or server performance, but it's still strange that this diff will be eg. 7 sec.
 
Last edited:

Nick2253

Wizard
Joined
Apr 21, 2014
Messages
1,633
That script seems like it's meant to check for performance, not time differences (which is how it's checking for performance). The 5-10 seconds seems to indicate that it takes 5-10 seconds to write and read from your database.

I don't know exactly what your script is doing, but if you can modify it, I would do the following:
  1. Get PHP Time and save in variable
  2. Write MySQL NOW()
  3. Read that line
  4. Compare with PHP time variable.
This should tell you if the time is actually different, and not just different because of slow performance (since PHP time and MySQL now are generated before the write/read operations)
 

King

Cadet
Joined
Feb 15, 2018
Messages
3
Thanks Nick2253 i agree with you it's not really a time difference and the script basically checks the server like the 4 steps you proposed. This means that the performance should be that slow, which the server performance indicators do not really show. Running it on a hosted server has never been an issue and it has much less ressources than my own server. I will ahem to find another solution than a jail.
 
Status
Not open for further replies.
Top