Hi can any help me how timedatctl works
my understanding are
if system clock sysnc with NTP serivce through internet system time will be updated to current date and time.
If system clock sync with NTP it will update the RTC every 11 min is this right ?
but my observation :
please find the image where i tested by disabling the NTP serves
After enabling NTP service only local + Universal time got updated but Not RTC time why ?
Related
I am trying to change Date and time settings to UTC+10 Canberra,Sydney,Melbourne on the instance but it always keep rolling back to UTC+00 Monrovio, Reykjavik. Doesn't matter even if I select set time zone to automatic.enter image description here
The zone "australia-southeast1-b" on the provided screenshot is a deployment area for Google Cloud Platform resources, where the physical hosts, your VM instance is running on, are physically located. This is a geographical zone. It is not relevant to time.
To configure Date and Time in Windows, you should:
set correct time zone in Windows and
make sure a time server is reachable
Google Cloud Engine VM instance is just a virtual machine that boots up with hardware clock set to UTC as many modern servers do nowadays.
If you looked at the VM instance logs in the GCP Console you'd see that VM BIOS reports time in UTC
2019/10/3 14:9:44 Begin firmware boot time
After a while BIOS hands over to the bootloader
2019/10/3 14:9:45 End firmware boot time
Booting from Hard Disk 0...
The OS boots up. Behind the scene the OS time service recognizes the system timezone, then sets up and synchronizes time with the time source. From that time forward running programs and services report events based on the local system time:
...
2019/10/03 09:10:05 GCEWindowsAgent: GCE Agent Started (version 4.6.0#1)
In the Windows Event Log you should see entries made by the Time-Service:
Log Name: System
Source: Time-Service
Level: Information
The time provider NtpClient is currently receiving valid time data from metadata.google.internal,0x1 (ntp.m|0x1|0.0.0.0:123->169.254.169.254:123).
The time service is now synchronizing the system time with the time source metadata.google.internal,0x1 (ntp.m|0x1|0.0.0.0:123->169.254.169.254:123).
In the command prompt you can ensure that the time configuration and state are correct:
C:\Users\user>systeminfo | find /i "Time"
System Boot Time: 10/3/2019, 9:09:49 AM
Time Zone: (UTC-06:00) Central Time (US & Canada)
Hence you don't need synchronizing time neither manually or with any startup script. The time service will do this for you: synchronize the system time shortly after the system boot and keep it in sync afterwards.
All you need is to set correct Time zone and the Internet time server for Windows, and then make sure the time server is reachable via the network.
If you can't wait for the timesync cycle completion, you can logon to Windows and force time synchronization manually:
net stop W32Time
net start W32Time
w32tm /resync /force
To O.P
Answer to your question if I understand correctly, your answer is:
timedatectl set-timezone "Australia/Melbourne"
I'm switching with the phycore i.MX6 som from phytec's dev kit to an own board. The usermanuals for both the som and devkit can be found on phytec's page. Now I want to configure the rtc to keep the time during reboot's and poweroffs.
The battery (in my case supercap) is connected to the VDD_BAT pin of the phycore i.MX6 som (page 10). The internal PMIC is the da9062 connected via the i2c bus which is configured in the som dtsi file as rtc1.
imx6qdl-phytec-phycore-som.dtsi:
...
aliases {
rtc1 = &da9062_rtc;
};
...
&i2c3 {
pmic#58 {
da9062_rtc: rtc {
compatible = "dlg,da9062-rtc";
};
};
};
This file I didn't touch at all.
Next, I told the kernel to take his hwclock and systime time from rtc1 instead of rtc0:
CONFIG_RTC_HCTOSYS_DEVICE="rtc1"
CONFIG_RTC_SYSTOHC_DEVICE="rtc1"
The driver is being loaded correctly as far as I can tell:
dmesg | grep rtc
[ 2.489836] da9063-rtc da9062-rtc: rtc core: registered da9063-rtc as rtc1
[ 2.499713] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-rtc-lp as rtc2
[ 3.260348] da9063-rtc da9062-rtc: setting system clock to 2000-01-01 02:37:55 UTC (946694275)
and
cat /sys/class/rtc/rtc1/name
da9063-rtc da9062-rtc
Now, I can set the time via date and transfer it to the hwclock via
hwclock --systohc
.
After rebooting the system and hwclock is set to the previously set date which is fine. After cutting the power the clock gets reset.
I've measured the voltage of the supercap which is around 220mV. The datasheet of the da9062 tells me the chip does have an regulator for the battery which needs to be configured (Table 127: BBAT_CONT (0x0C5)).
As far as I understand the kernel/rtc subsystem, the driver for the rtc should take care of the charging of the battery or provide an userspace interface so I can do it myself. But I can't find anything on this topic.
I am using yocto to build the kernel/image for my board.
Is there something I'm missing or do I need to patch the driver myself in order to charge the supercap? Maybe there's an option in the devicetree to set the charging voltage and current for the cap?
I appreciate any ideas and suggestions, thanks.
Aparently the driver does not support charging a battery/supercap out of the box and it has exclusive access rights to the i2c device address which prevents userspace applications to access the device.
My solution to this problem is to set those values before the driver takes over:
Since this i2c bus is already configured in my barebox devicetree, I can access it before I boot the kernel (provided barebox is compiled with the i2c subsystem enabled in menuconfig). Here I can run a script which sets the BBAT and PD registers to enable charging the supercap.
Though, the cleaner solution would be to extend the driver and provide a userspace interface for this functionality.
Another possible solution I did not investigate would be to check if the driver can be compiled as a module, so I could unload the module, set the registers and load it again.
I have a dev environment and a production environment. The time() function returns the correct timestamp in my dev env but in my production environment time() is exactly 59 seconds behind!
The version of PHP is 7.0.3 on both environments.
This can't be a timezone issue since the difference is only one minute and the PHP default timezone is the same in both environments (America/Los Angeles).
It is now 10:48:29 am and here is the output from calling this function simultaneously in both environments (or at least as fast as I can press enter on the console).
Dev environment (is correct)
php > echo date('h:i:s A');
10:48:29 AM
Production environment (is one minute behind)
echo date('h:i:s A');
10:47:31 AM
Same happens with the time() function
Dev environment (is correct)
php > echo time();
1568742851
Production environment (is one minute behind)
echo time();
1568742792
And 1568742851 - 1568742792 = 59 secs
I know i could just add 59 seconds to the timestamp time() returns but that just seems like a hack and does not solve the problem. I would like to please get advice as to how to fix my production environment.
Confirm that you are allowing NTP traffic to your production OS environment. You can confirm that your server is properly communicating to NTP by running the following command ntpq -c peers If you receive a Connection refused prompt you don't have proper connectivity. You will need to configure an inbound firewall rule allowing UDP traffic on port 123. Once this is done, restart your NTP service service ntpd restart and rerun the ntpq -c peers command
I believe the system clock on your production and dev machine is unsync, Regardless of the version of PHP or Operating System, Just like #g_bor mentioned in comment.
Don't get confused by the time zone, Just run the command date +%s on system shell to print timestamp on both machines, If you have no permission (can't login with ssh), You can prepare the PHP file which contains system('date +%s');, And then, Upload to your web server and open the browser to check the timestamps on both your machines.
I'm using Linux CentOS 6.6 in my VPS Server
and installed php 5.6.12 and above (php 7)
also i did config php.ini date.timezone=Europe/Amsterdam
and use in php file something this :
date_default_timezone_set('Europe/Amsterdam'); echo date("Y-m-d H:i:s");
but the time is not exactly it show me more than real time Amsterdam !!! also i checked for other timezone area but it was same problem !
for example if real time Amsterdam is 10:50:30 show me 10:58:27 !
you can see 8 min is more than real time !!!
I thought my problem was in version of php, so i updated it from php5.6.12 to php7.0.7 but it was not solved !
I am convinced this has nothing to do with php. When you enter in the shell date - what do you get?
What about contacting the server provider regarding the time difference?
To me it looks like the NTP service is not running. Check Google for NTP Service or this link.
If you have full root access to your server may be installing an NTP service would be an option.
I found this problem
I had a Webmin Control Panel on my Linux Server, so i checked System Time (in the left Menu: Hardware-> System Time) module and set Timezone to UTC, after i saw that system time was 8 min more than right time UTC !
I just set Minute and Second time according UTC world time at worldtimeserver
thank you for attention
I'm using a Raspberry Pi, and upon startup it's sending an e-mail with the time and an IP address. The problem is that the time is not correct, it's the time from last time the system was shut down. When I log in through ssh and do a date command, I get the correct time. In other words, the e-mail is sent before the system has updated its time.
I was thinking of automatically running ntpdate on boot, but after reading up on it it seems like a bad idea due to the many risks of error.
So, can I somehow wait until the time has been uppdated before continuing in a script?
There is a tool included in the ntp reference implementation for this very purpose. The utility has a rather cryptic name: ntp-wait. Five minutes with the man page and you will be all set.