3 ms·
> This time is then converted to local time per the OS timezone setting. What exactly do you mean by this? As in, what part of your software stack is doing thi
by IgorPartola 4y ago
> This time is then converted to local time per the OS timezone setting.
What exactly do you mean by this? As in, what part of your software stack is doing this. IIRC if you set your OS to be in UTC then anything at the OS level will only speak UTC. Databases and your own software will do what they are told to do but systemd etc. will all speak UTC only. Even running date in the shell should give you a UTC timestamp.
- viraptor 4y agoYour system time is totally different from what userspace cares about. Go ahead, run "TZ=UTC date" (or a different timezone if you're using UTC already). I'm not even sure what you mean by the OS speaking a certain timezone. Basic "time()" will return seconds from the epoch UTC regardless of your system timezone. Things that care about timezones will use relevant conversions.
- cyberpunk 4y agoI’ve seen junior sysadmins and developers repeating this for years also. Don’t know where it comes from. Apart from this issue, I’ve never once see an error due to the tz presentation settings on a server, and I have spent 20 years running many thousands of servers at a time. shrug. Let them have to adjust in grafana/kibana if it helps them sleep I guess..
- IgorPartola 4y agoOf course userspace may convert from what time() returns by spec to any given timezone. But it only does so if you instruct it like you did with TZ= or if it is programmed to do so somehow. I have not delved into systemd’s code but I can’t imagine it arbitrarily converts anything away from UTC time if /etc/localtime is set to UTC.
- viraptor 4y agoTZ doesn't do anything magic. It just tells libc you want your local timezone to be something different than the default. It affects output formatting in a way that the app mostly doesn't need to deal with if it only works with one timezone. I'm not even sure what claim you're making now, but the original msg is just wrong. If an app uses libc, it uses TZ setting - regardless if it's systemd or date or something else. > but I can’t imagine it arbitrarily converts anything away from UTC time if /etc/localtime is set to UTC. It really depends on which part of systemd you mean. There's lots of code in there and quite a few bits deal with timezones explicitly. (Since it sets it for users to begin with) But for basic display it sure uses TZ and localtime as set by the user - and it can be different than the system default. https://github.com/systemd/systemd/blob/cccc14c5a88f000931c67eaf3d776825aa2607f7/src/shared/logs-show.c#L417 https://github.com/systemd/systemd/blob/cccc14c5a88f000931c6...
- IgorPartola 4y agoYou and I are saying the same thing in different ways, except the part about systemd. I didn’t realize it did anything with timezones because I keep thinking of it as just modern initd but I guess it goes beyond that. I didn’t realize that if you remove all mention of local timezones from /etc/ that a user could still break systemd by setting their own TZ.