14. Time settings

This section describes how to retrieve or configure time and date settings using the supported BMC interfaces.

You can configure the BMC to use two different time synchronization methods: NTP or manual.

If the time synchronization method is manual, you must manually set the date and time using the CLI, REST or IPMI interfaces.

If the time synchronization method is NTP, the date and time is automatically synchronized using the NTP protocol (with the timesyncd service as the NTP client). This either uses the default systemd NTP servers (time.google.com) or other specified NTP servers.

Note

Time zones are not supported by OpenBMC. All times read from BMC are assumed to be in UTC.

14.1. BMC command line

  • To get the current date and time, use the date command. Refer to the Linux man pages for details of this command.

  • To get the current time synchronization method of BMC:

    $ busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod
    
  • To set the time synchronization method of BMC:

    # Set BMC time synchronization method to NTP
    $ busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
    
    # Set BMC time synchronization method to Manual
    $ busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.Manual"
    
  • To confirm that setting of time mode is applied, you can check the “NTP service” status of the output of the timedatectl command.

    $ timedatectl
           Local time: Sat 2021-06-19 16:14:23 UTC
           Universal time: Sat 2021-06-19 16:14:23 UTC
           RTC time: Sat 2021-06-19 16:14:24
           Time zone: n/a (UTC, +0000)
           System clock synchronized: yes
           NTP service: active
           RTC in local TZ: no
    

If the “NTP service” field is reported as “active” then BMC timesyncd service is syncing time with either a configured NTP server or the default one.

  • To manually add NTP servers in CLI, you can use the following command:

    $ busctl set-property  xyz.openbmc_project.Network /xyz/openbmc_project/network/eth0 xyz.openbmc_project.Network.EthernetInterface NTPServers as 1 "<ntp_server>"
    

14.2. REST API

  • To get current time synchronization method of BMC use the following curl command:

    $ curl -k https://<bmcip>/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod -u <bmcuser>:<bmcpass>
    
  • To set time synchronization method of BMC use the following command:

    # Set BMC time synchronization method to NTP
    $ curl -k -X  PUT  -d '{"data": "xyz.openbmc_project.Time.Synchronization.Method.NTP" }' https://<bmcip>/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod -u <bmcuser>:<bmcpass>
    
    # Set BMC time synchronization method to Manual
    $ curl -k -X  PUT  -d '{"data": "xyz.openbmc_project.Time.Synchronization.Method.Manual" }' https://<bmcip>/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod -u <bmcuser>:<bmcpass>
    
  • To manually add NTP servers with the CLI, you can use the following command:

    $ curl -k -X  PUT -d '{"data": ["<ntp_server>"] }' https://<bmcip>/xyz/openbmc_project/network/eth0/attr/NTPServers
    

Note

It is possible to get the BMC time using REST interface using the following command, however the time is returned as epoch time, that is as microseconds after 1970:01:01.

$ curl -b cjar -k https://<bmcip>/xyz/openbmc_project/time/bmc

14.3. IPMI

Time synchronization mode setting is not supported over the IPMI interface. Assuming the BMC is not in NTP mode, you can get or set time using the following IPMI commands:

# Set time and date
$ ipmitool -I lanplus -U <user> -P <password> -H <hostip/hostname> sel time set "DD/MM/YYYY HH:MM:SS"
# Get time and date
$ ipmitool -I lanplus -U <user> -P <password> -H <hostip/hostname> sel time get

Note

Setting the time over the IPMI interface if the BMC time synchronization method is NTP, will fail. Please use the CLI or REST interface to set the time synchronization method to manual before setting the time.

14.4. Redfish

Setting the time and date of BMC is not supported.