Previous section   Next section

Recipe 14.2 Setting the Time

14.2.1 Problem

You want to set the clock on the router.

14.2.2 Solution

You can set the internal system clock using the clock set in enable mode:

Router#clock set 14:27:22 March 9 2003

Some high-end routers, such as the 4500 series, 7000 series, 7200 series, and 7500 series, have a battery-protected calendar function that continues to keep time even if the router is temporarily powered off. You can set this calendar function using the calendar set command in enable mode:

Router#calendar set 14:34:39 March 9 2003

In both cases, the router will accept either "hh:mm:ss day month year" or "hh:mm:ss month day year" notation.

14.2.3 Discussion

Every Cisco router has an internal system clock. When the router boots, the internal system clock starts to maintain the current date and time. If there is no battery-protected calendar in the router, the clock will start with a default initial value of Monday March 1, 1993 at midnight. If you want accurate time, you need to set it manually as described earlier, or use the automated method given in Recipe 14.5.

As we said, most high-end routers have an internal battery-powered clock called a calendar. Router calendars are able to maintain accurate time and date information, even during power interruptions. When the router initializes, it automatically synchronizes the internal system clock with the date stored with the calendar.

You can view the current calendar time using the following command:

Router>show calendar
14:34:39 UTC Sat Mar 9 2003
Router>

If your router returns an error message when you issue this command, then it does not contain a calendar:

Router#show calendar
                ^
% Invalid input detected at '^' marker.
   
Router#

Note, however, that the "clock" time and the "calendar" time are kept on different clocks that may differ at any given moment. After router initialization, these two clocks may drift apart or be set independently of one another. Fortunately, Cisco's IOS does provide methods of synchronizing the two time sources after initial power up.

To set the calendar to the internal clock time, use the following command in enable mode:

Router#clock update-calendar
Router#

You can also set the internal clock to the calendar time using the command:

Router#clock read-calendar
Router#

Both the internal system clock and calendar use 24-hour time notation rather than 12-hour A.M./P.M. notation.


  Previous section   Next section
Top