M
M
MURZELLO2019-06-20 21:46:38
linux
MURZELLO, 2019-06-20 21:46:38

How to synchronize the time with a script in Linux indicating your Timezone?

Available LTE WiFi Router

Device parameters
5d0bc819be7dc576279082.png
it is quite natural that there is practically nothing on such hardware - neither the zoneinfo or localtime folders nor the ntpdate utility.
After turning on or rebooting the router, the system date and time shows an incomprehensible time zone.
I connect to it via SSH and synchronize the time: (so, just in case)
rdate time.nist.gov
In response, I get the correct date and Moscow time. (hooray, it's already closer!)
After that, I adjust the time zone 2 hours ago: (Kaliningrad) .
export TZ=UTC-2
And I get what I need!
Correct time
5d0bcd216a21d233092111.png

However, when the device is rebooted, all these settings are lost.
Is it possible to automate all this with a script when the system boots?
Can anyone share? In Linux, I don’t understand anything at all, everything described above is from a search in Yandex.
Help me please!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
brar, 2019-06-20
@brar

As an option, open the /usr/zte/zte_conf/config/userseting_nvconfig.txt file
and set your NTP settings in it:

sntp_timezone=2
sntp_server0=time.windows.com
sntp_server1=pool.ntp.org
sntp_server2=europe.pool.ntp.org

J
jcmvbkbc, 2019-06-20
@jcmvbkbc

How to synchronize the time with a script in Linux indicating your Timezone?

No way, the internal time in Linux is always in UTC. TZ is not needed for clock synchronization.
TZ is a common environment variable, it only affects date/time C functions, and different sessions on the same machine may well have different TZ settings.
You can set it for ash in /etc/profile or ~/.profile.

M
MURZELLO, 2019-06-20
@poreeff

Somewhere - on one of the Linux forums, I read that usually such scripts (which climb the Internet - as in this case, for time synchronization) are placed in the appropriate folder in /etc/network :
5d0bd745b6da8760511309.pngOr they create a new one for it, with the prefix post- up to run the script AFTER connecting. But, will if-post-up.d work in my case, all of a sudden they are registered somewhere else...

P
pfg21, 2019-06-20
@pfg21

make a crutch.
register a script in cron to start the system

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question