How to set time and date using unix command

May 8th, 2009 by @HKw@! | Filed under Unix.

date
Date displays the date and time of the system, used by root it can also be used to change the date and time of the system.

If you just enter:

date

You will get the date of the system, like this;

Fri May 18 19:36:53 MYT 2009

You can set the date by using root user:

Usage:

date nnddhhmm[[cc]yy][.ss]

Note:

  • nn = month of the year (01 to 12)
  • dd = day of the month (01 to 31)
  • hh = hour of the day (00 to 23)
  • mm = minute of the hour (00 to 59>
  • cc = The first to digits of the year
  • yy = The last two digits of the year
  • .ss = The seconds

Example:

date –set 06:00 ;sets the time to 6:00AM

OR

hwclock

hwclock is a tool for accessing the Hardware Clock. You can display the current time, set the Hardware Clock to a specified time, set the Hardware Clock to the System Time, and set the System Time from the Hardware Clock.

SYNOPSIS

hwclock -r or hwclock –show
hwclock -w or hwclock –systohc
hwclock -s or hwclock –hctosys
hwclock -a or hwclock –adjust
hwclock -v or hwclock –version
hwclock –set –date=newdate
hwclock –getepoch
hwclock –setepoch –epoch=year

Example of change date and time.

hwclock –set –date=’08/18/07 21:08:40′ –localtime

Share

Leave a Reply

BlogCatalog