zoukankan      html  css  js  c++  java
  • 解决Windows和Ubuntu双系统时间不一致问题

    Ubuntu下运行:

    timedatectl set-local-rtc 1 --adjust-system-clock

    或者Windows下运行:

    Reg add HKLMSYSTEMCurrentControlSetControlTimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

    参考如下:

    timedatectl --help 的执行结果如下:

    timedatectl [OPTIONS...] COMMAND ...
    
    Query or change system time and date settings.
    
      -h --help                Show this help message
         --version             Show package version
         --no-pager            Do not pipe output into a pager
         --no-ask-password     Do not prompt for password
      -H --host=[USER@]HOST    Operate on remote host
      -M --machine=CONTAINER   Operate on local container
         --adjust-system-clock Adjust system clock when changing local RTC mode
    
    Commands:
      status                   Show current time settings
      set-time TIME            Set system time
      set-timezone ZONE        Set system time zone
      list-timezones           Show known time zones
      set-local-rtc BOOL       Control whether RTC is in local time
      set-ntp BOOL             Enable or disable network time synchronization

    更详细的参数解释:

    能够识别的命令行选项如下:
    
    --no-ask-password
    在执行特权操作时 不向用户索要密码。
    
    --adjust-system-clock
    当使用 set-local-rtc 命令时, 若使用了此选项, 则表示根据RTC时间来更新系统时钟。 若未使用此选项, 则表示根据系统时钟来更新RTC时间。
    
    --monitor
    与 timesync-status 命令一起使用, 表示监视 systemd-timesyncd.service(8) 的状态并不断刷新输出。可以使用 Ctrl+C 终止监视。
    
    -a, --all
    显示全部的 systemd-timesyncd.service(8) 属性,无论这些属性是否已设置。
    
    -p, --property=
    仅显示指定的 systemd-timesyncd.service(8) 属性。若未指定任何属性则显示全部已设置的属性。 参数必须是一个例如 "ServerName" 这样的属性名称。 可以多次使用此选项,以显示多个属性。
    
    --value
    当使用 show-timesync 命令显示属性时, 仅显示属性的值(不显示"="与属性名称)。
    
    -H, --host=
    操作指定的远程主机。可以仅指定一个主机名(hostname), 也可以使用 "username@hostname" 格式。 hostname 后面还可以加上 SSH监听端口(以冒号":"分隔)与容器名(以正斜线"/"分隔), 也就是形如 "hostname:port/container" 的格式, 以表示直接连接到指定主机的指定容器内。 操作将通过SSH协议进行,以确保安全。 可以通过 machinectl -H HOST 命令列出远程主机上的所有容器名称。IPv6地址必须放在方括号([])内。
    
    -M, --machine=
    在本地容器内执行操作。 必须明确指定容器的名称。
    
    -h, --help
    显示简短的帮助信息并退出。
    
    --version
    显示简短的版本信息并退出。
    
    --no-pager
    不将程序的输出内容管道(pipe)给分页程序。

     参考:http://www.jinbuguo.com/systemd/timedatectl.html

    The following options are understood:
    
    --no-ask-password
        Do not query the user for authentication for privileged operations.
    
    --adjust-system-clock
        If set-local-rtc is invoked and this option is passed, the system clock is
        synchronized from the RTC again, taking the new setting into account. Otherwise, the
        RTC is synchronized from the system clock.
    
    -H, --host=
        Execute the operation remotely. Specify a hostname, or a username and hostname
        separated by "@", to connect to. The hostname may optionally be suffixed by a
        container name, separated by ":", which connects directly to a specific container on
        the specified host. This will use SSH to talk to the remote machine manager instance.
        Container names may be enumerated with machinectl -H HOST.
    
    -M, --machine=
        Execute operation on a local container. Specify a container name to connect to.
    
    -h, --help
        Print a short help text and exit.
    
    --version
        Print a short version string and exit.
    
    --no-pager
        Do not pipe output into a pager.
    
    The following commands are understood:
    
    status
        Show current settings of the system clock and RTC, including whether network time
        synchronization is on. Note that whether network time synchronization is on simply
        reflects whether the systemd-timesyncd.service unit is enabled. Even if this command
        shows the status as off, a different service might still synchronize the clock with
        the network.
    
    set-time [TIME]
        Set the system clock to the specified time. This will also update the RTC time
        accordingly. The time may be specified in the format "2012-10-30 18:17:16".
    
    set-timezone [TIMEZONE]
        Set the system time zone to the specified value. Available timezones can be listed
        with list-timezones. If the RTC is configured to be in the local time, this will also
        update the RTC time. This call will alter the /etc/localtime symlink. See localtime(5)
        for more information.
    
    list-timezones
        List available time zones, one per line. Entries from the list can be set as the
        system timezone with set-timezone.
    
    set-local-rtc [BOOL]
        Takes a boolean argument. If "0", the system is configured to maintain the RTC in
        universal time. If "1", it will maintain the RTC in local time instead. Note that
        maintaining the RTC in the local timezone is not fully supported and will create
        various problems with time zone changes and daylight saving adjustments. If at all
        possible, keep the RTC in UTC mode. Note that invoking this will also synchronize the
        RTC from the system clock, unless --adjust-system-clock is passed (see above). This
        command will change the 3rd line of /etc/adjtime, as documented in hwclock(8).
    
    set-ntp [BOOL]
        Takes a boolean argument. Controls whether network time synchronization is active and
        enabled (if available). This enables and starts, or disables and stops the
        systemd-timesyncd.service unit. It does not affect the state of any other, unrelated
        network time synchronization services that might be installed on the system. This
        command is hence mostly equivalent to: systemctl enable --now
        systemd-timesyncd.service and systemctl disable --now systemd-timesyncd.service, but
        is protected by a different access policy.
    
        Note that even if time synchronization is turned off with this command, another
        unrelated system service might still synchronize the clock with the network. Also note
        that, strictly speaking, systemd-timesyncd.service does more than just network time
        synchronization, as it ensures a monotonic clock on systems without RTC even if no
        network is available. See systemd-timesyncd.service(8) for details about this.
  • 相关阅读:
    一个强大的在线开发IDE: CodeRun Studio
    PyQuery: 一个类似jQuery的Python库
    jQuery的图片剪切插件
    SVN导出两个版本之间的差异文件
    javascript中的focus()光标定位
    零分,裸奔真危险
    Django 截取中英文混合字符串
    360与金山网盾
    20100301:IE6的葬礼
    两个与jQuery相关的资源:导航条与提示
  • 原文地址:https://www.cnblogs.com/jacen789/p/9689577.html
Copyright © 2011-2022 走看看