date and clock sync

Post your questions and help other users.

Moderator: Martin

Post Reply
wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

date and clock sync

Post by wfrcrd » 03 Jan 2018 14:23

Hi!
There is a way to perform the date and clock sync via NTP using a root command , or a script?

Thank you !!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: date and clock sync

Post by Desmanto » 03 Jan 2018 16:32

You can use ntpd, which is part of the busybox.
Usage: ntpd [-dnqNwl -I IFACE] [-S PROG] [-p PEER]...

NTP client/server

-d Verbose
-n Do not daemonize
-q Quit after clock is set
-N Run at high priority
-w Do not set time (only query peers), implies -n
-S PROG Run PROG after stepping time, stratum change, and every 11 mins
-p PEER Obtain time from PEER (may be repeated)
If -p is not given, 'server HOST' lines
from /etc/ntp.conf are used
-l Also run as server on port 123
-I IFACE Bind server to IFACE, implies -l
Go to http://www.pool.ntp.org and find the nearest server to you location. For example, I will use German. Then you can change the time by using Execute root Command

Code: Select all

ntpd -n -q -p de.pool.ntp.org
Add a debug dialog after it to see the result.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: date and clock sync

Post by wfrcrd » 04 Jan 2018 01:51

Thank you Desmanto,
I need more hints:
how can I invoke busybox from the flow?
What action should I perform?


Thank you.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: date and clock sync

Post by Desmanto » 04 Jan 2018 05:27

You mean to use command from busybox? No extra action needed as long as you have installed busybox. When you install the busybox you should already have all the command from busybox linked to the system path (usually /system/xbin/). ntpd can be used directly, or you can just add busybox at the beginning of the command, to make sure it use the binary from busybox

Code: Select all

busybox ntpd -n -q -p de.pool.ntp.org
Most of the time, the "busybox" is not needed anymore. You can try the command in terminal emulator first, by typing su first to switch to root shell. If you don't have the ntpd (not found), then install busybox first, or maybe the binary is installed in different path.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

wfrcrd
Posts: 116
Joined: 27 May 2015 08:57

Re: date and clock sync

Post by wfrcrd » 04 Jan 2018 13:31

Yes it works!
Simpy edit an action->execute root command->
in the command line put " ntpd -n -q -p de.pool.ntp.org " (as you said),
and wait for the next minute on the statusbar clock to see the time upgrade.

Thank you!

Post Reply