Thursday, March 3, 2016

[Quick Tips - Date/Time]: How to set System Date and Time in Linux

How to set System Date and Time in Linux

In this post will show you how to set system date and time on the command prompt in Redhat Linux.  As a first step login to the system as a root user and continue with the below steps to complete the date and time setup. Very important that always in your environment make sure all the system sync with the right date and time each other, if you have an ntp server, will always prefer in high priority to sync your systems with the ntp server, in future post will explain more about ntp in detail.
Step 1: Check the current system date and time by executing the below command in shell prompt
# date
Mon   Sep   28   10:45:11  GMT 2015
Step 2: Syntax to set date
# date   +%D   -s    YYYY-MM-DD
Example
# date   +%D   -s    2015-09-2015
Step 3: Syntax to set time
# date   +%T    -s    HH:MM:SS
Example
# date   +%T    -s    13:50:25
Step 4: Syntax to set date and time in one command
# date   -s    “29  SEP  2015  13:50:25”
or
# date  —-set     “29     SEP    2015      13:50:25     GMT”
Step 5: Check the current status of new date and time
# date
Mon   Sep   29   13:50:25   GMT 2015
In my next post will show you how to sync hardware clock with system time in RedHat Linux.

No comments: