1

How to change system default date time on Debian permanently?

I tried following command

# date --set="12 MAY 2012 12:12:12 PM"

# hwclock --systoh

But date-time is getting changed temporary.

After few seconds, current date is popping again.

Did I miss something?

Update

System is guest OS on virtual box, where ntp is not enabled.

While ntp is enabled in host OS.

3 Answers 3

2

Looks like NTP is setting your time over internet.... You need to stop NTP.
Try these commands:

sudo service ntp stop

To prevent it from starting at boot:

sudo update-rc.d -f ntp remove  

You may need to uninstall ntpd if needed. Even though you uninstall ntpd, ntpdate will be still installed in your system. You can add exit status to disable it.
Add exit 0 to /etc/default/ntpdate.

2

Just execute this command:

dpkg-reconfigure tzdata

You will be asked for the timezone.

debian docs recommends using tzconfig, but it seems to be deprecated in favor of dpkg-reconfigure tzdata

2
  • I see nothing about timezones in the question.
    – jwodder
    May 12, 2016 at 17:16
  • @jwodder - ...but user wants to change the machine local time. This is the better way if your desired local time match a timezone one. I disagree with the down vote.
    – Manolo
    May 12, 2016 at 17:34
1

If you have a systemd system then you have to use timedatectl:

timedatectl set-ntp false 
timedatectl set-time '2018-12-12 12:12:12'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.