Courseiva
SystemPrivileged EXEC

clock set [hh:mm:ss] [day] [month] [year]

Sets the system clock on a Cisco IOS device from the privileged EXEC mode, used to manually configure the router's time when NTP is not available.

Definition: clock set [hh:mm:ss] [day] [month] [year] is a Cisco IOS privileged exec command. Sets the system clock on a Cisco IOS device from the privileged EXEC mode, used to manually configure the router's time when NTP is not available.

Overview

The `clock set` command is a fundamental IOS command used to manually configure the system clock on a Cisco router or switch from privileged EXEC mode. Accurate timekeeping is critical for network devices because timestamps in logs, debug output, and syslog messages rely on the system clock to provide context for troubleshooting and security auditing. Without a correct clock, correlating events across multiple devices becomes nearly impossible, and features like NTP (Network Time Protocol) authentication or certificate validation may fail.

The `clock set` command is typically used in lab environments, during initial device deployment before NTP is configured, or as a fallback when NTP servers are unreachable. It directly sets the hardware calendar (if present) and the software system clock. The command requires privilege level 15 (enable password) and does not affect the running configuration; the time is lost on reload unless saved to the startup configuration via `clock timezone` and `clock summer-time` commands, or if the device has a hardware calendar that persists.

In production networks, NTP is preferred because it maintains accuracy automatically, but `clock set` remains essential for initial setup and emergency situations. The command accepts time in 24-hour format (hh:mm:ss), day (1-31), month (three-letter abbreviation or full name), and year (four digits). It is important to note that the clock set command does not validate the input for logical consistency (e.g., February 30 is accepted but may cause unexpected behavior).

Also, the command sets the time immediately, which can affect routing protocols like OSPF that use timestamps for adjacency formation, though OSPF uses its own dead interval timers and is not directly impacted by system clock changes. In summary, `clock set` is a simple but powerful tool for manual time configuration, and understanding its behavior is essential for CCNA and CCNP candidates.

Syntax·Privileged EXEC
clock set [hh:mm:ss] [day] [month] [year]

When to Use This Command

  • Setting the correct time on a router in a lab or isolated network without NTP servers.
  • Synchronizing the router's clock to a known accurate time before enabling logging or debugging to ensure timestamps are meaningful.
  • Correcting the time after a power outage or when the router has been offline and the clock has drifted.
  • Setting the clock during initial router setup before configuring NTP as a fallback.

Parameters

ParameterSyntaxDescription
hh:mm:ssHH:MM:SSSpecifies the current time in 24-hour format. Hours range from 0 to 23, minutes and seconds from 0 to 59. Leading zeros are optional for hours but recommended for clarity. Common mistake: using 12-hour format or omitting leading zeros for hours (e.g., 3:00:00 instead of 03:00:00) which is actually valid but may cause confusion.
day<1-31>Specifies the day of the month as a number from 1 to 31. The value must be valid for the given month; for example, day 31 is invalid for April. A common mistake is entering an out-of-range day, which IOS rejects with an error message.
monthWORDSpecifies the month using the full English name (e.g., January) or a three-letter abbreviation (e.g., Jan). The abbreviation is case-insensitive. Common mistake: using numeric month (e.g., 01) which is not accepted; IOS expects a string.
year<1993-2035>Specifies the year as a four-digit number. Valid range is 1993 to 2035 on most IOS platforms. Common mistake: using a two-digit year (e.g., 23) which is rejected; the full year must be entered.

Command Examples

Set clock to a specific date and time

clock set 14:30:00 15 March 2025

No output is displayed on success. The command silently sets the clock. Use 'show clock' to verify.

Set clock with incorrect format (missing seconds)

clock set 14:30 15 March 2025
% Incomplete command.

The command requires the full hh:mm:ss format. Omitting seconds results in an error.

Understanding the Output

The 'clock set' command produces no output on success. To verify the clock, use 'show clock'. The 'show clock' output displays the current time, timezone, and whether the clock is authoritative.

A properly set clock shows the correct time and date. If the clock is not set, it may show '*00:00:00 UTC Mon Mar 1 1993' or similar. In production, ensure the clock is accurate for logging and routing protocols like OSPF that rely on timestamps.

Configuration Scenarios

Set system clock during initial router deployment

A network engineer is deploying a new Cisco router in a remote branch office. NTP servers are not yet reachable because the WAN link is down. The engineer needs to set the correct time manually to ensure logs have accurate timestamps until NTP is configured.

Topology

R1 (single router, no connections yet)

Steps

  1. 1.Step 1: Access the router via console and enter privileged EXEC mode: Router> enable
  2. 2.Step 2: Set the clock to the current local time. For example, if the time is 2:30 PM on March 15, 2025: Router# clock set 14:30:00 15 March 2025
  3. 3.Step 3: Verify the clock setting: Router# show clock
  4. 4.Step 4: (Optional) Set the time zone and summer time if needed: Router(config)# clock timezone EST -5, Router(config)# clock summer-time EDT recurring
Configuration
! No configuration saved; clock set is immediate
Router# clock set 14:30:00 15 March 2025
Router# show clock
14:30:00.123 EST Sat Mar 15 2025

Verify: Use 'show clock' to display the current system time. Expected output shows the time, time zone (if configured), and date. Example: '14:30:00.123 EST Sat Mar 15 2025'

Watch out: The clock set command does not update the hardware calendar on all platforms. On routers without a hardware calendar, the time resets to the default (typically 00:00:00 UTC on Jan 1, 1993) after a reload. Always configure 'clock timezone' and 'clock summer-time' to persist time zone settings, and consider using 'calendar set' if the device has a hardware calendar.

Correcting time after NTP failure

A router's NTP association has failed due to a misconfigured NTP server. The system clock has drifted significantly, causing log timestamps to be inaccurate. The engineer needs to manually set the correct time as a temporary fix while troubleshooting NTP.

Topology

R1(Gi0/0)---10.0.1.0/30---(Gi0/0)R2 (NTP server on R2, but unreachable)

Steps

  1. 1.Step 1: Enter privileged EXEC mode on R1: Router> enable
  2. 2.Step 2: Check current time and NTP status: Router# show clock, Router# show ntp status
  3. 3.Step 3: Manually set the correct time. For example, 9:45 AM on April 10, 2025: Router# clock set 09:45:00 10 April 2025
  4. 4.Step 4: Verify the time is correct: Router# show clock
  5. 5.Step 5: Troubleshoot NTP: Router# debug ntp packets (if needed)
Configuration
! No configuration saved; manual override
Router# clock set 09:45:00 10 April 2025
Router# show clock
09:45:00.456 UTC Thu Apr 10 2025

Verify: Use 'show clock' to confirm the time. Also use 'show ntp status' to see if NTP synchronization is re-established later. Expected output for show clock: '09:45:00.456 UTC Thu Apr 10 2025'

Watch out: If NTP is still configured and reachable, it will overwrite the manually set time within a few minutes. To prevent this, disable NTP with 'no ntp server' or 'no ntp peer' before setting the clock manually. Also, ensure the time zone is correctly configured; otherwise, the displayed time may be in UTC.

Troubleshooting with This Command

The `clock set` command is primarily used to correct time issues, but it can also be part of troubleshooting when time-sensitive features behave unexpectedly. Healthy output from `show clock` shows a reasonable time and date, with the correct time zone and summer time if configured. Problem indicators include: time that is obviously wrong (e.g., year 1993), time zone missing or incorrect, or the clock showing 'time not set' after a reload.

Common symptoms that lead to using `clock set` include: syslog messages with timestamps that are hours off, debug output showing impossible times, routing protocol adjacencies failing due to certificate time validation (e.g., IPsec), or NTP synchronization failures because the local clock is too far off (NTP will not sync if offset > 1000 seconds). When troubleshooting, first check `show clock` to see the current time. If it is incorrect, use `show clock detail` to see the time source (e.g., 'Hardware calendar' or 'NTP').

If the source is 'user' (manual), then the clock was set with `clock set`. Next, verify the time zone with `show running-config | include clock timezone`. If the time zone is missing, the clock may display UTC, which can be confusing.

To diagnose NTP issues, use `show ntp status` and `show ntp associations`. If the clock is manually set and NTP is configured, NTP will eventually override it; this can be seen by the time source changing from 'user' to 'NTP'. A step-by-step diagnostic flow: 1) Check `show clock` – if time is wrong, proceed. 2) Check `show ntp status` – if NTP is not synced, check connectivity to NTP server. 3) If NTP is unreachable, use `clock set` to set an approximate time. 4) After setting, verify with `show clock`. 5) If NTP becomes reachable later, monitor `show ntp status` to see if it syncs.

Correlate `show clock` with `show logging` to ensure timestamps align with expected events. Also, `debug ntp packets` can show NTP exchanges, but use with caution in production. In summary, `clock set` is a quick fix for time inaccuracies, but the root cause (e.g., NTP misconfiguration) must be addressed for long-term stability.

CCNA Exam Tips

1.

CCNA exam tip: The 'clock set' command is only available in privileged EXEC mode (enable), not global configuration mode.

2.

CCNA exam tip: The time format is 24-hour (hh:mm:ss). The day is numeric, month is spelled out (e.g., March), and year is four digits.

3.

CCNA exam tip: If you see '% Incomplete command', you likely omitted a required parameter like seconds or month.

4.

CCNA exam tip: After setting the clock, always verify with 'show clock' to ensure the change took effect.

Common Mistakes

Mistake 1: Using the command in global configuration mode instead of privileged EXEC mode. Consequence: 'Invalid input detected' error.

Mistake 2: Forgetting to include seconds (hh:mm instead of hh:mm:ss). Consequence: '% Incomplete command' error.

Mistake 3: Using an incorrect month abbreviation or numeric month. Consequence: 'Invalid input detected' error.

clock set [hh:mm:ss] [day] [month] [year] vs ntp server [ip]

Both commands affect the system clock but differ fundamentally in method and permanence. They are often confused because both aim to set the time, yet one is a temporary manual adjustment while the other enables automatic synchronization. Understanding their distinct roles is crucial for proper network time management.

Aspectclock set [hh:mm:ss] [day] [month] [year]ntp server [ip]
ScopeLocal device onlyNetwork time source
Configuration modePrivileged EXECGlobal configuration
PersistenceNot saved to configSaved in running-config
PrecedenceOverridden by NTPOverrides manual clock set when reachable
Typical useInitial boot or troubleshootingOngoing time accuracy

Use clock set [hh:mm:ss] [day] [month] [year] when you need an immediate, one-off time setting for testing or when NTP is unavailable.

Use ntp server [ip] when you require persistent, accurate time synchronization for logging, authentication, and network protocols.

Platform Notes

On IOS-XE (e.g., Catalyst 9000 switches), the `clock set` command syntax is identical to classic IOS. However, IOS-XE devices often have a hardware calendar that persists time across reloads; the `clock set` command updates both the system clock and the hardware calendar. To set only the hardware calendar, use `calendar set`.

On NX-OS (e.g., Nexus switches), the equivalent command is `clock set` in privileged EXEC mode, but the syntax is slightly different: `clock set <time> <day> <month> <year>` (same order). NX-OS also supports `clock timezone` and `clock summer-time`. On ASA firewalls, the command is `clock set` in privileged EXEC mode, but the syntax is `clock set <hh:mm:ss> <month> <day> <year>` (month before day).

For example: `clock set 14:30:00 March 15 2025`. ASA also uses `clock timezone` and `clock summer-time`. On IOS-XR (e.g., ASR 9000), the `clock set` command is not available in the same form; instead, use `clock set` in the XR environment, but the syntax is `clock set <time> <day> <month> <year>` (similar to IOS).

However, IOS-XR strongly recommends using NTP and the command may be restricted. In older IOS versions (12.x), the `clock set` command works the same, but the valid year range may be narrower (e.g., 1993-2035). In 15.x and 16.x, the range is typically 1993-2035 as well.

Some platforms may accept years up to 2099. Always verify with `show clock` after setting. Note that on some platforms, the `clock set` command requires the device to have a hardware clock; otherwise, the time is lost on reload.

For CCNA/CCNP studies, focus on the standard IOS syntax and behavior.

Related Commands

Practice for the CCNA 200-301

Test your knowledge with practice questions covering all CCNA 200-301 exam domains.

Practice CCNA 200-301 Questions