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)

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

Or

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

2)

 
# 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

The simplest way to set the date is as described in the manual page.

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

So that would be:

date 100218002006

thanks for your answer but can we include the seconds also.

If this is a production server:

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:

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

note that it uses your example 2 of setting time.

and configure and start ntp.

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.