Sunday, January 22, 2012

Time

CentOS-Setting the time.
http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html

Set time: (two methods)
Note than when setting server time to GMT, set your local environment first to GMT: export TZ=GMT0 (link to current GMT)

1)Set hardware clock and sync system (OS) time to match: (hctosys)
Set hardware clock: /sbin/hwclock --utc --set --date="07/30/2008 23:16:30"
(Set either --utc or --localtime)

Then match system clock: hwclock --hctosys
(Set the System Time from the Hardware Clock.)


2)Set system (OS) clock and sync hardware time to match: (systohc)
Set system time (Linux OS time):
date -s 10:20
date 073023162008.30
July 30, 2008 11:16 pm and 30 seconds
date MMDDhhmm.ss
(month, day, hour, minute, year and dot seconds - seconds optional)
(where hours are from 00 to 24)
Set hardware clock to system clock in UTC: /sbin/hwclock --systohc --utc
(UTC preferred for Linux because it allows automatic accounting of daylight savings time. Microsoft\\
OS's use local time. UTC will mess up the time setting on a dual boot system which hosts a Microsoft OS)
Set hardware clock in localtime to current system clock: /sbin/hwclock --systohc
(Same as: /sbin/hwclock --systohc --localtime)



Ubuntu-Setting the time.
If not, you can do this via the commandline in Linux :-
In Linux, set the date and time to what it currently is. For example if it’s 10:20am local time:
user@server:~$ sudo date -s 10:20

Then update the hardware clock accordingly, and force this to be considered “localtime”:
user@server:~$ sudo /sbin/hwclock --systohc --localtime

Check to make sure it looks right:
user@server:~$ sudo /sbin/hwclock --localtime

Sync between hardware clock and system clock:
user@server:~$ sudo /sbin/hwclock --hctosys --localtime

No comments: