2

I am running sudo date +%m/%d/%Y -s 7/14/2010 command to change date. It changes fine except I want it to pick up the current time as well, and not start the time from 00:00:00 on 7/14/2010.

3 Answers 3

6

Just extend the call to include hour information too:

sudo date +"%m/%d/%Y %H:%M:%S" -s "7/14/2010 10:00:00"
1
  • Perfect, i actually needed sudo date +"%m/%d/%Y %H:%M:%S" -s "7/14/2010 date +%T" but i didn't fully understand formats
    – gAMBOOKa
    Jul 14, 2010 at 10:55
2

If you need accurate time, use ntpdate or better run ntpd daemon:

Example:

/usr/sbin/ntpdate clock.redhat.com
2

It is often a good idea to sync the BIOS clock if there is that much of an offset after changing. This can be done via:

hwclock --systohc

Typically distributions write to BIOS on a shutdown.

1
  • +1 I've gotten into the habit of doing this any time I set the date/time. Jul 14, 2010 at 22:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .