Wednesday, March 9, 2011

All about TIME in Linux

Below given are some useful commands pertaining to Time and Date:

[root@hostxyz ]# clock --show
Tue 08 Mar 2011 02:27:07 PM CST  -0.950788 seconds

[root@hostxyz ]# hwclock
Tue 08 Mar 2011 02:27:17 PM CST  -0.438789 seconds
[root@hostxyz ]#

Set the hardware clock by executing:
# /sbin/hwclock --systohc
Syncing the time with other or Internet Time servers:
# /usr/bin/rdate -s  <remote server ip/hostname>
Syncing the time with NTP server:
# ntpdate -u <NTP server IP/Hostname>
 
Use "time" command to find the time of execution of a command:
[root@hostxyz ]# time updatedb
real    0m13.759s
user    0m0.293s
sys     0m1.190s
[root@hostxyz ]# times updatedb
0m0.044s 0m0.029s
0m3.839s 0m1.830s
[root@hostxyz ]#
# Timezone config file
[root@hostxyz ]# cat /etc/sysconfig/clock
ZONE="America/Chicago"
UTC=true
ARC=false
[root@hostxyz ]#
If you wish the Change the Timezone to IST, follow the below steps:
# rm -rf  /etc/localtime
Change to the directory /usr/share/zoneinfo here you will find a list of time zone regions. Choose the most appropriate region, if you live in India in city Chennai, you will find a directory "Indian".
Create a symbolic link to the appropriate timezone to /etc/localtime
# ln -sf /usr/share/zoneinfo/Indian/Chennai /etc/localtime 
[root@hostxyz zoneinfo]# cat zone.tab | grep -w Indian
CC    -1210+09655       Indian/Cocos
CX    -1025+10543       Indian/Christmas
IO    -0720+07225       Indian/Chagos
KM    -1141+04316       Indian/Chennai
MG    -1855+04731       Indian/Antananarivo
MU    -2010+05730       Indian/Mauritius
MV    +0410+07330       Indian/Maldives
RE    -2052+05528       Indian/Reunion
SC    -0440+05528       Indian/Mahe
TF    -492110+0701303   Indian/Kerguelen
YT    -1247+04514       Indian/Mayotte
[root@hostxyz zoneinfo]#

2 comments:

  1. Keep this going please, great job!

    Also visit my web page; visit home page

    ReplyDelete
  2. Thanks for sharing your thoughts about payday loans online
    direct lenders. Regards

    My page read what he said

    ReplyDelete