Changing System Date and Time

 Changing the System Date and Time

Use the date command to set the date and time. For example, to set the date to April 1st, 1999, and the time to 09:00, log in as root and enter:

date 0401090099

Changing the date and time on a running system can have unexpected consequences. Users and administrators use system scheduling utilities (at, cron, and batch) to perform commands at specified times. If you change the effective date or time on the system, these commands may not execute at the desired times. Similarly, if your users use the make utility provided with the system, the commands specified in Makefiles may perform incorrectly. Always try to keep your system date and time accurate within reason.  Random changes of the date and time can be extremely inconvenient and possibly destructive to users' work.

If timed is running on the system, and it is a slave system, the time is reset by timed and not the date command. For more information, see the timed(1M) reference page.

 Setting the Time Zone

To set the time zone of the system, edit the file /etc/TIMEZONE. For a site on the east coast of the United States, the file might look something like this:

# Time Zone

TZ=EST5EDT

The line TZ=EST5EDT means:

The current time zone is Eastern Standard Time.

  •  It is 5 hours to the west of Greenwich Mean Time.
  • Daylight saving time applies here (EDT).

 

The TZ environment variable is read by init(1) when the system boots, and the value of TZ is passed to all subsequent processes. The time zone designation (such as EST) is simply passed through for your convenience. The important parts of the designation are the specification of the deviation from Greenwich Mean Time and the presence of the daylight savings time indicator.

 
Comments