Skip to main content

Set Date & Time in Red Hat



Setting timezone and synchronizing time with NTP

1. See what the current timezone is:
Type date and press enter
     You should see output like this:
Wed Sept  1 10:33:29 PDT 2012
2. What time zones are available by running the following command on the command line: 
Type ls /usr/share/zoneinfo/ and press enter

Note: If you want to change your time zone, then follow the step-3 and step-4.

3. Then simply delete the current timezone:
Type rm /etc/localtime and press enter
4. And replace it with a new timezone from /usr/share/zoneinfo. For example if your chosen zone is Pacific time:
Type cp /usr/share/zoneinfo/PST8PDT /etc/localtime and press enter

Network Time Protocol (NTP) is a standard way of synchronizing computer clocks across a network. Using NTP you can keep your server’s clock synchronized with super accurate atomic clocks located around the world. Computer clocks tend to “drift” so regularly synchronizing them with NTP servers helps keep them accurate.
5. The first step is to make sure you have the ntp program installed.
Type which ntpdate and press enter
6.  If its not available type:
Type yum install ntp and press enter

ntpd

To keep your server clock automatically synchronized you can run the ntpd daemon which is installed as part of the ntp package. Edit the /etc/ntp.conf file to comment out the following lines:
#server 127.127.1.0     # local clock
#fudge  127.127.1.0 stratum 10

 7. Finally type the following two commands to start the daemon and make it run automatically at boot up:

Type service ntpd start and press enter
Type chkconfig ntpd on and press enter

Setting the system clock

To set the system clock under Linux, use the date command. As an example, to set the current time and date to July 31, 11:16pm, type ``date 07312316'' (note that the time is given in 24 hour notation). If you wanted to change the year as well, you could type ``date 073123161998''. To set the seconds as well, type ``date 07312316.30'' or ``date 073123161998.30''. To see what Linux thinks the current local time is, run date with no arguments.

Setting the hardware clock

First Method:
To set the hardware clock, my favourite way is to set the system clock first, and then set the hardware clock to the current system clock by typing ``/sbin/hwclock --systohc'' (or ``/sbin/hwclock --systohc --utc'' if you are keeping the hardware clock in UTC). To see what the hardware clock is currently set to, run hwclock with no arguments. If the hardware clock is in UTC and you want to see the local equivalent, type ``/sbin/hwclock --utc''

Second Method:
Set the hardware clock to local time
hwclock --set --date="2012-04-19 16:45:05" --localtime
Set the hardware clock to UTC
hwclock --set --date="2011-04-19 20:45:05"  --utc

Setting the date

date +%Y%m%d -s "20120418''

Setting the Time

date +%T -s "11:14:00"

Setting the Date & Time

date -s "19 APR 2012 11:14:00"

Summary

  • /etc/sysconfig/clock sets whether the hardware clock is stored as UTC or local time.
  • Symlink /etc/localtime to /usr/share/zoneinfo/... to set your timezone.
  • Run ``date MMDDhhmm'' to set the current system date/time.
  • Type ``/sbin/hwclock --systohc [--utc]'' to set the hardware clock.

Comments

Popular posts from this blog

Red Hat Enterprise version list

Red Hat Enterprise Linux 6 Release/Update General Availability Date redhat-release Errata Date* Kernel Version RHEL 6 Update 4 TBA TBA TBA RHEL 6 Update 3 2012-06-20 2012-06-19 RHSA-2012-0862 2.6.32-279 RHEL 6 Update 2 2011-12-06 2011-12-06 RHEA-2011:1743 2.6.32-220 RHEL 6 Update 1 2011-05-19 2011-05-19 RHEA-2011:0540 2.6.32-131.0.15 RHEL 6 GA 2010-11-09 - 2.6.32-71 Codename: Santiago (based on a mix of Fedora 12, Fedora 13, and several modifications) Red Hat Enterprise Linux 5 Release/Update General Availability Date redhat-release Errata Date* Kernel Version RHEL 5 Update 9 TBA TBA TBA RHEL 5 Update 8 02/20/2012 02/20/2012 RHEA-2012:0315 2.6.18-308 RHEL 5 Update 7 07/21/2011 07/20/2011 RHEA-2011:0977 2.6.18-274 RHEL 5 Update 6 01/13/2011 01/12/2011 RHEA-2011:0020 2.6.18-238 RHEL 5 Update 5 03/30/2010 03/30/2010 RHEA-2010:0207 2.6.18-194 RHEL 5 Update 4 09/02/2009 09/02/2009 ...

Installation Red Hat Enterprise & make standered partition

First of all select DVD and reboot your computer. After Booting from DVD you will get below screen. Select  Install or Upgrade an Existing System and press Enter. If you get the following screen then let Anaconda take another step. Select your preferred  Language and Select  Keyboard Layout . In Following Screen you will be able to see 4 Installation Methods, Let me explain Methods here:- Local CD/DVD – It is obvious that If you use CD/DVD media then Choose this option. Hard Drive – Select this if you have dumped your source into any other Linux partition. NFS Directory – You can select this option if you have configured NFS server. URL – Select this if you want to install using FTP or HTTP Source link. So for step by step installation of RHEL 6 I had  Local CD/DVD Installation Method. If you are not sure about your media then select  OK to verify else select  Skip . If your media is fine till now it will take ...

MBR, Primary, Extended & Logical partition in Red Hat

MBR, Primary, Extended & Logical partition in Red Hat Hard disk and storage device are normally divided up into smaller chunks called partitions. So that different parts of it can be formatted with different file system or used for different purposes. For example, one partition could contain user home directories while another could contain system data and logs; by placing the data in two separate file system on two separate partitions, even if a user fills up the home directories partition with data, the system data partition may have space. Most Red Hat Enterprise Linux system on the x86 and x86-64 processor architectures use the MBR partitioning format for their hard disk. This is the same format that is used by most Microsoft Windows systems, and dates back to the IBM PC.                              Storage device: /dev/sda In this format, the first sector of the disk is reser...