Saturday, April 07, 2007

Date Time Clocks

Setting the timezone:
ln -sf /usr/share/zoneinfo/your/zone /etc/localtime

Setting the timezone for a particular user:
export TZ=America/Chicago

Show time in a given timezone:
# relative to the /usr/share/zoneinfo/ directory
zdump Japan
zdump America/Chicago
zdump US/Central

# absolute path to zonefile
zdump /etc/localtime
zdump /usr/share/zoneinfo/America/Chicago

View date and time:
date
date --utc #universal time

Set the date and time:
date -s "16:15:00" # just the time
date -s "16:15:00 April 7, 2007" # date and time
date 040716552007.00 # the fields being MMDDhhmmCCYY.ss

Verify connectivity with NTP server:
ntpdate -q time.nist.gov

Several common time servers:
clock.redhat.com
clock2.redhat.com
ns1.tuxfamily.org
time.nist.gov
time.apple.com

Manually use NTP to set time:
ntpdate time.nist.gov
ntpdate -v time.nist.gov # verbose output

Use NTPd to automatically set date and time:
/etc/init.d/ntpd start #ntpd must be installed, of course

Monitor NTPd:
ntpdc -p
ntpdc -p -n


http://www.linuxsa.org.au/tips/time.html
http://www.vanemery.com/Linux/RH-Linux-Time.html

No comments: