EdgeRouter Lite & EdgeRouter 4: date command ignores timezone, shows UTC

I am the happy owner of a brand new EdgeRouter 4. Put OpenWrt master on it, all fine, except Busybox date keeps showing UTC time instead of the CET time (all the other OpenWrt devices in the network happily print CET time with similar settings).

I don't think this device has a hardware clock, hwclock reports /dev/misc/rtc is missing e.g. Pointers are appreciated.

Syncing through LuCI's system tab doesn't make the time over SSH display as CET (LuCI itself seems to recalculate it correctly, showing CET).

root@OpenWrt:~# dmesg |grep -i clock
[    0.344050] clocksource: OCTEON_CVMCOUNT: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.442353] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    4.588601] clocksource: Switched to clocksource OCTEON_CVMCOUNT
[    4.651885] platform 1180068000000.uctl: clocks initialized.
root@OpenWrt:~# uci show system
system.@system[0]=system
system.@system[0].hostname='OpenWrt'
system.@system[0].ttylogin='0'
system.@system[0].log_size='64'
system.@system[0].urandom_seed='0'
system.@system[0].zonename='Europe/Brussels'
system.@system[0].timezone='CET-1CEST,M3.5.0,M10.5.0/3'
system.@system[0].log_proto='udp'
system.@system[0].conloglevel='8'
system.@system[0].cronloglevel='5'
system.ntp=timeserver
system.ntp.server='0.openwrt.pool.ntp.org' '1.openwrt.pool.ntp.org' '2.openwrt.pool.ntp.org' '3.openwrt.pool.ntp.org'
system.ntp.use_dhcp='0'

Syntax error.
You forgot time /2 from spring. (you only define date, but not time)

'CET-1CEST,M3.5.0/2,M10.5.0/3'

EDIT:
hmmm. might not be that, as the original string in LuCI does not have that:
https://github.com/openwrt/luci/blob/master/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua#L356

I was about to say: sharp eye, but the functional OpenWrt devices have the exact same line there.

Out of curiosity: which shell you use?
The default ash? (or bash? or something)

Just thinking what might be reason for similar symptoms discussed a month ago in

(Busybox ash uses /etc/TZ and /tmp/TZ, but bash might want "TZ" shell variable, or something like that)

I'm using plain ash. Thing is, I see /etc/TZ as a symlink to /tmp/TZ, but that is broken (ie no /tmp/TZ):

root@OpenWrt:~# ll /etc/TZ 
lrwxrwxrwx    1 root     root             7 Dec  9 17:12 /etc/TZ -> /tmp/TZ
root@OpenWrt:~# ll /tmp/TZ 
ls: /tmp/TZ: No such file or directory

I see this both on the ER4 and on other hardware where it just displays CET time.

That /tmp/TZ should get set when the system boots.

 OpenWrt SNAPSHOT, r15151-13961da6ce
 -----------------------------------------------------

root@router1:~# cat /tmp/TZ
EET-2EEST,M3.5.0/3,M10.5.0/4

You should be able to set it by rebooting, or with
/etc/init.d/system reload

root@router1:~# cat /tmp/TZ
EET-2EEST,M3.5.0/3,M10.5.0/4
root@router1:~# rm /tmp/TZ
root@router1:~# date
Thu Dec 10 21:08:32 UTC 2020
root@router1:~# /etc/init.d/system reload
root@router1:~# date
Thu Dec 10 23:08:44 EET 2020
root@router1:~#

Weird, something going wrong there then (on multiple devices). I already tried switching to another time zone and back, both in LuCI and over SSH, to no avail.

There's definitely some weirdness going on:

root@OpenWrt:~# echo 'CET-1CEST,M3.5.0,M10.5.0/3' > /tmp/TZ 
root@OpenWrt:~# date
Thu Dec 10 21:07:57 UTC 2020
root@OpenWrt:~# service system reload
root@OpenWrt:~# date
Thu Dec 10 21:08:34 UTC 2020
root@OpenWrt:~# /etc/init.d/system reload
root@OpenWrt:~# date
Thu Dec 10 21:09:31 UTC 2020
root@OpenWrt:~# ls -l /tmp/TZ
ls: /tmp/TZ: No such file or directory

After removing /tmp/TZ myself and doing another full run of it:

root@OpenWrt:~# ls /tmp/TZ
ls: /tmp/TZ: No such file or directory
root@OpenWrt:~# echo 'CET-1CEST,M3.5.0,M10.5.0/3' > /tmp/TZ 
root@OpenWrt:~# ls /tmp/TZ
/tmp/TZ
root@OpenWrt:~# /etc/init.d/system reload
root@OpenWrt:~# ls /tmp/TZ
ls: /tmp/TZ: No such file or directory
root@OpenWrt:~# date
Thu Dec 10 21:10:59 UTC 2020

For me it works ok, also on a device with master built today:
(and with the the default C lib, musl)

 OpenWrt SNAPSHOT, r15182-8663072854
 -----------------------------------------------------

root@router3:~# cat /tmp/TZ
EET-2EEST,M3.5.0/3,M10.5.0/4
root@router3:~# date -u
Thu Dec 10 21:14:32 UTC 2020
root@router3:~# date
Thu Dec 10 23:14:35 EET 2020
root@router3:~#
root@router3:~# rm /tmp/TZ
root@router3:~# date -u
Thu Dec 10 21:14:47 UTC 2020
root@router3:~# date
Thu Dec 10 21:14:48 UTC 2020
root@router3:~#
root@router3:~# /etc/init.d/system reload
root@router3:~#
root@router3:~# cat /tmp/TZ
EET-2EEST,M3.5.0/3,M10.5.0/4
root@router3:~# date -u
Thu Dec 10 21:15:06 UTC 2020
root@router3:~# date
Thu Dec 10 23:15:08 EET 2020

Yeah I don't know what's happening here.

  • On my ER4, /tmp/TZ is not there. Time displays in UTC. Master build from December 9th.
  • On my GS1900-10HP, /tmp/TZ is there. Time displays in CET. Same master build from December 9th.
  • On my RT-AC57U, /tmp/TZ is not there. Time displays in CET. Master build from December 3rd.
  • On my EA6350v3, /tmp/TZ is not there. Time displays in CET. Same master build from December 9th.

Two ideas:

Have you installed the zoneinfo packages on the device that fails?
Do you have /tmp/localtime there?
(as that would lead to deleting /tmp/TZ. See /etc/init.d/system for reference, or the message that I referenced above)

Somehow misformatted /etc/config/system
(but that should not affect the situation when you manually change /tmp/TZ)

I do. Version 2020d-1.

I do:

# ls -l /tmp/localtime 
lrwxrwxrwx    1 root     root            35 Dec 10 21:10 /tmp/localtime -> /usr/share/zoneinfo/Europe/Brussels

I removed the symlink now (and /tmp/localtime as well), reloaded the system service, but no difference.

I already copied a working config off another system and same issue. So I don't think that's at play, no.

I will reboot the system sometime tonight, and see what's going on tomorrow.

Well, then there shouldn't be any /tmp/TZ as the info from the full zoneinfo is used via /tmp/localtime symlink.

So here I am again :smile: I removed /etc/TZ, linked /etc/localtime to /usr/share/zoneinfo/ and rebooted. Still UTC though :roll_eyes:

Typo?
/tmp/localtime

See the init script above.

I guess that something goes wrong with the full zoneinfo data. Do you really need the full zoneinfo for something?

It's both in /etc/ and /tmp, the symlink. I removed the one in /etc, reloaded the system service, no difference.

I don't need the full zoneinfo, if you say OpenWrt has everything onboard by default, I'll run a build without and check again.

Musl & busybox have the capability to apply the POSIX string included in the config file. But some advanced apps (like php, real webservers, some python apps) might want the full zoneinfo, if they want direct access to all timezones.

zoneinfo is rarely installed.

Please read the explanation from the message that I linked above.

@hnyman Sorry for being a bit dense. At this point, all my builds have zoneinfo removed. There's no /tmp/localinfo either. Just /etc/TZ linking to a (now present) /tmp/TZ. But the time is still printed in UTC no matter what (timezone's set like before).

# cat /etc/config/system 

config system
	option hostname 'OpenWrt'
	option ttylogin '0'
	option log_size '64'
	option urandom_seed '0'
	option log_proto 'udp'
	option conloglevel '8'
	option cronloglevel '5'
	option zonename 'Europe/Brussels'
	option timezone 'CET-1CEST,M3.5.0,M10.5.0/3'

[...]

What I did notice, however, is that on my EdgeRouter Lite I set up today, the same thing is happening. Another octeon device showing UTC. My UCI defaults scripts set up a Europe/Brussels timezone at first installation, and on all my other devices that works like a charm. Looks like something else is at play here...

Perhaps one of your devices have utils/zoneinfo installed?