lunedì 11 novembre 2013

RedHat CentOS setting Date and Time

Date and Time Setup
The date command allows the superuser to set the system date and time manually:
Change the current date. Type the command in the following form at a shell prompt, replacing the YYYY with a four-digit year, MM with a two-digit month, and DD with a two-digit day of the month:

~]# date +%D -s YYYY-MM-DD

For example, to set the date to 2 June 2010, type:
~]# date +%D -s 2010-06-02

Change the current time. Use the following command, where HH stands for an hour, MM is a minute, and SS is a second, all typed in a two-digit form:

~]# date +%T -s HH:MM:SS

If your system clock is set to use UTC (Coordinated Universal Time), add the following option:
~]# date +%T -s HH:MM:SS -u
For instance, to set the system clock to 11:26 PM using the UTC, type:
~]# date +%T -s 23:26:00 -u

Change TimeZone Using /etc/localtime File

For this example, assume that your current timezone is UTC as shown below. You would like to change this to Pacific Time.
# date
Mon Sep 17 22:59:24 UTC 2010
On some distributions (for example, CentOS), the timezone is controlled by /etc/localtime file.
Delete the current localtime file under /etc/ directory
# cd /etc
# rm localtime
All US timezones are located under under the /usr/share/zoneinfo/US directory as shown below.
# ls /usr/share/zoneinfo/US/
Alaska          Arizona         Eastern         Hawaii          Michigan        Pacific
Aleutian        Central         East-Indiana    Indiana-Starke  Mountain        Samoa
Note: For other country timezones, browse the /usr/share/zoneinfo directory
Link the Pacific file from the above US directory to the /etc/localtime directory as shown below.
# cd /etc
# ln -s /usr/share/zoneinfo/US/Pacific localtime
Now the timezone on your Linux system is changed to US Pacific time as shown below.
# date
Mon Sep 17 23:10:14 PDT 2010

Nessun commento: