Setting Date and Time

This section describes how to set the time zone, date, and time.

Setting Time Zone

To see the current time zone, list the contents of the /etc/timezone directory.

admin@Switch$cat /etc/timezone
Etc/UTC

To set the time zone, run the dpkg-reconfigure tzdata command as root.

admin@Switch$sudo dpkg-reconfigure tzdata
Package configuration
  +-----------------------------------+ Configuring tzdata +------------------------------------+
  | Please select the geographic area in which you live. Subsequent configuration questions     |
  | will narrow this down by presenting a list of cities, representing the time zones in which  |
  | they are located.                                                                           |
  |                                                                                             |
  | Geographic area:                                                                            |
  |                                                                                             |
  |                                         Africa                                              |
  |                                         America                                             |
  |                                         Antarctica                                          |
  |                                         Australia                                           |
  |                                         Arctic                                              |
  |                                         Asia                                                |
  |                                         Atlantic                                            |
  |                                         Europe                                              |
  |                                         Indian                                              |
  |                                         Pacific                                             |
  |                                         SystemV                                             |
  |                                         US                                                  |
  |                                         Etc                                                 |
  |                                                                                             |
  |                                                                                             |
  |                          <Ok>                              <Cancel>                         |
  |                                                                                             |
  +---------------------------------------------------------------------------------------------+

Navigate through the menus to set the appropriate time zone.

               +-----------------------+ Configuring tzdata +-----------------------+
               | Please select the city or region corresponding to your time zone.  |
               |                                                                    |
               | Time zone:                                                         |
               |                                                                    |
               |                           Alaska                                   |
               |                           Aleutian                                 |
               |                           Arizona                                  |
               |                           Central                                  |
               |                           Eastern                                  |
               |                           Hawaii                                   |
               |                           Indiana-Starke                           |
               |                           Michigan                                 |
               |                           Mountain                                 |
               |                           Pacific                                  |
               |                           Pacific-New                              |
               |                           Samoa                                    |
               |                                                                    |
               |                                                                    |
               |                 <Ok>                     <Cancel>                  |
               |                                                                    |
               +--------------------------------------------------------------------+

 Then, the selected time zone should be displayed.

Current default time zone: 'US/Eastern'
Local time is now:      Mon Dec  7 21:15:30 EST 2015.
Universal Time is now:  Tue Dec  8 02:15:30 UTC 2015.

Verify if the time zone is correctly set.

admin@Switch$cat /etc/timezone
US/Eastern

Setting Date and Time

The switch has a hardware clock that maintains system time, even when the switch is rebooted or powered off. The hardware clock is powered by a battery on the system board. When the switch is running, PicOS maintains its own software clock. During switch boot up, the hardware clock is copied to the software clock maintained by PicOS. The software clock is then referenced for anything that requires time keeping.  During switch shut down, the software clock is copied back to the hardware clock.

To set the date and time on the software clock, use the date command as root.

admin@Switch$sudo date --set 2015-12-07
Mon Dec  7 00:00:00 EST 2015
admin@Switch$sudo date --set 13:21:00
Mon Dec  7 13:21:00 EST 2015

To display the current date and time, use the date command without arguments.

admin@Switch$date
Mon Dec  7 13:23:00 EST 2015

To set the date and time on the hardware clock, use the hwclock command as root.

 

Copyright © 2024 Pica8 Inc. All Rights Reserved.