Setting the Time Zone

Problem

You want to set the time zone.

Solution

Configure the local time zone. You can do this in a number of different styles:

[edit system] aviva@router1# set time-zone UTC-8 [edit system] aviva@router1# set time-zone PST8PDT [edit system] aviva@router1# set time-zone America/Los_Angeles

 

Discussion

When you set the time on the router, the default time zone is UTC (Coordinated Universal Time). You might be more familiar with UTC's old name, GMT, or Greenwich Mean Time, or with the term zulu, which is the U.S. military term for the time at the prime meridian, which runs through Greenwich, England. If you have a global organization and want to run all the routers on your time in a common global time zone, just leave the default time zone unchanged. You don't have to configure anything to make this happen.

If you want to change the time zone, use the time-zone statement in configuration mode. You can't set the local router time and the time zone at the same time because you set the time with an operational mode command, and you set the time zone in configuration mode.

The JUNOS time-zone statement is based on the FreeBSD time zone function, which is controlled with the FreeBSD tzsetup utility. The JUNOS time zone list is the same as the FreeBSD list, which you can find in the file /usr/share/zoneinfo/zone.tab.

You can specify the time zone by hour-offset from UTC, by common time zone three-letter abbreviation, or by continent/city pairings. There are several dozen different zone names; type set time-zone ? to get the entire list. This recipe shows three ways to set the local time in California.

To verify that the time zone change has taken effect, use the show system uptime command:

aviva@router1> show system uptime Current time: 2005-03-15 11:10:22 PST System booted: 2005-03-15 03:09:57 PST (08:00:25 ago) Protocols started: 2005-03-15 03:11:31 PST (07:58:51 ago) Last configured: 2005-03-15 11:10:19 PST (00:00:03 ago) by aviva 11:10AM up 8 hrs, 1 user, load averages: 0.07, 0.02, 0.01

You can see that the time zone has changed to PST, and the current hour has changed from 19:00 UTC to 11:00 Pacific Time.

While consistent time zones aren't really necessary, you will find it helpful if all the routers on your network use the same time zone, whether it's UTC or the local time zone. All events recorded in system logging and tracing files that you keep on the router all have a timestamp associated with them that consists of the date and the time but gives no indication of the time zone. If you are trying correlate events on different routers, it will be much easier if the routers are in the same time zone.

Категории