Right way to change time for a RHEL server | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

Right way to change time for a RHEL server

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-07-2013
RHCE RHCE is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 21 August 2014, 8:20 AM EDT
Posts: 76
Thanks: 11
Thanked 0 Times in 0 Posts
Right way to change time for a RHEL server

I had the query of what would be the right approach to change the time on the RHEL server. I have the following ways to do that:

1)

Code:
# date -s "2 OCT 2006 18:00:00"

Or

Code:
 
# date --set="2 OCT 2006 18:00:00"

2)

Code:
 
# date +%Y%m%d -s "20081128"

The second option though would only change the date but not the time.

I hope, my query is clear about what is the right way to change time for a RHEL server.

Please revert with the reply to my query.

Regards

Last edited by Scott; 01-07-2013 at 04:24 AM.. Reason: Code tags, please...
Sponsored Links
    #2  
Old 01-07-2013
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 21 August 2014, 5:48 PM EDT
Location: Zürich
Posts: 8,472
Thanks: 330
Thanked 1,046 Times in 913 Posts
The simplest way to set the date is as described in the manual page.


Code:
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

So that would be:

Code:
date 100218002006

Sponsored Links
    #3  
Old 01-07-2013
RHCE RHCE is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 21 August 2014, 8:20 AM EDT
Posts: 76
Thanks: 11
Thanked 0 Times in 0 Posts
thanks for your answer but can we include the seconds also.
    #4  
Old 01-07-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 20 August 2014, 11:31 PM EDT
Location: NM
Posts: 10,174
Thanks: 273
Thanked 784 Times in 733 Posts
If this is a production server:


Code:
1. you should be using ntp services, not manually changing dates
2. When you manually change date/time over any substantial time value 
   you run the risk of breaking things like cron jobs, or application software 
   with services that are time dependent.

answer to your question after you have the date completely correct, you can set time:


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

note that it uses your example 2 of setting time.

and configure and start ntp.
Sponsored Links
    #5  
Old 01-08-2013
admin_xor's Avatar
admin_xor admin_xor is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 8 April 2014, 5:55 AM EDT
Posts: 452
Thanks: 13
Thanked 79 Times in 76 Posts
Well as pointed out, it's recommended to use the NTP servers for updating date/time using the ntpdate command.

If this is not available, then the next recommended method is to use the hwclock --hctosys command. This sets the system time as BIOS time.

date command should always be avoided as setting date and time with this command introduces errors in time which could mess things up like kerberos.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Time Sync issue on RHEL 5.3 uday123 Red Hat 2 10-12-2009 09:58 AM
Date time issues on RHEL sumitb74 UNIX for Dummies Questions & Answers 5 07-21-2008 06:46 AM
RHEL 4 U5 - Server immediate shutdown mr_bold UNIX for Advanced & Expert Users 2 08-04-2007 04:33 AM
RHEL 3 - how to change the SNMP community strings? BG_JrAdmin Red Hat 0 06-19-2006 04:22 PM
To simultaneously update password change in two server at a time s_chandrakar Shell Programming and Scripting 0 11-07-2005 09:25 AM



All times are GMT -4. The time now is 05:57 PM.