• Set time in Linux system

    This document will help you in modifying server clock and timezone,You can keep the hardware clock in UTC or localtime.

    Linux looks at /etc/localtime to determine the current time of your machine ,Timezone files are located in /usr/share/zoninfo/ ,So if you are in Saudi Arabia (Riyadh) and want to configure the time on the server to reflect the current time of your zone ,you need to make a a symbolic link from /etc/localtime to a file in /usr/share/zoneinfo directory that corresponds with what timezone you are in.
    EX.

    ln -sf /usr/share/zoneinfo/Asia/Riyadh /etc/localtime

    When the system boots,it run /sbin/hwclock script that copy the current hardware clock time to the system clock.

    To set the hardware clock ,You have to set the system clock first ,then set the hardware clock :

    [root@raafat ~]# date -s 'Thu Aug 29 09:29:13 AST 2013'
    [root@raafat ~]#/sbin/hwclock --systohc
    [root@opsview ~]# hwclock
    Thu 29 Aug 2013 10:09:02 AM AST -0.828390 seconds
    
    Use the date command to verify that your timezone is changed
    
    [root@opsview ~]# date
    Thu Aug 29 10:09:05 AST 2013
    [root@opsview ~]#

    Categories: Linux

    Comments are currently closed.