【问题标题】:how can I set the timezone in Linux if there's no /etc/timezone file nor a /usr/share/zoneinfo如果没有 /etc/timezone 文件也没有 /usr/share/zoneinfo,如何在 Linux 中设置时区
【发布时间】:2012-06-05 00:06:17
【问题描述】:

我需要在 Linux 系统(嵌入式busybox 发行版)上设置时区,但我没有 /etc/timezone 也没有 /usr/share/zoneinfo。如何设置时区?

我将硬件时钟设置为 UTC: hwclock --set --date=18:15:30 --utc 然后认为我可以在 /etc/profile 中使用“export TZ=PST8PDT”来获取正确的日期时间,但这似乎不起作用。我仍然看到这个:

# date
Wed May 30 18:17:42 PDT 2012

谢谢! 罗恩

【问题讨论】:

  • “设置时区”是什么意思?您将使用什么作为(例如)夏令时更改的数据源?
  • 你用的是什么libc?如果您使用uclibc,它可能是/etc/TZ (see)
  • 是的弗洛里安,我正在使用 uclibc 和 /etc/TZ 似乎是正确的答案......! :)
  • 但是 #cat /etc/TZ PST8PDT 仍然不能解决问题:(
  • @cerr 如果你想写入文件,你必须调用echo 'PST8PDT' > /etc/TZ

标签: linux time timezone embedded busybox


【解决方案1】:

必须在 /etc/TZ 中设置正确的时区,使用 --set 和 --utc 标志将 hwclock 设置为 utc,并使用 hwclock --systohc 将系统时间存储在硬件时钟中。

【讨论】:

    【解决方案2】:

    将此添加到 /etc/inittab:

    setenv TZ CDT

    CDT (Central) 是时区。

    【讨论】:

    • 我没有可用的 setenv... :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 2019-07-08
    • 1970-01-01
    • 2016-08-26
    • 1970-01-01
    • 2016-04-29
    相关资源
    最近更新 更多