4

I use ArchLinux and I have had problems with my system time for many months.

Previously it was working, but once I updated my PC, the system time was shifted at every startup (like it wasn't detecting timezone, while timezone in rc.conf was and is correct).

Then I added hwclock and it was the same, and removed it. If I remember correctly, this seems to have solved the problem.

When Daylight Saving time changed in my country, The time was shifting by 1 hour at every startup (no matter how many times I set system time manualy or by ntpdate).

I again tried to fix this, and now it has many hour shift like prevously (The shift value is difference of UTC and local time). And now, seems that my system time is unchangable. I set time with date -s ... and ntpdate pool.ntp.org for example... but these measures do not seem to persist after a reboot. I tried it with hwclock daemon running, ntpd running, and none of them running in DAEMONS. I'm really confused about this.

I dont use windows very much. And I know booting windows can cause problems in linux with the system time. But thats not my problem. Every time I boot windows and linux, I can reset system time by hand or ntpdate command. So you can suppose I have not any windows on my machine.

I just want to my system time work and not changed automatically (via ntp or something), just set it manually (by hand, or ntpdate command) when I want. Please help.

Here is my rc.conf

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# DAEMON_LOCALE: If set to 'yes', use $LOCALE as the locale during daemon
# startup and during the boot process. If set to 'no', the C locale is used.
# HARDWARECLOCK: set to "", "UTC" or "localtime", any other value will result
#   in the hardware clock being left untouched (useful for virtualization)
#   Note: Using "localtime" is discouraged, using "" makes hwclock fall back
#   to the value in /var/lib/hwclock/adjfile
# TIMEZONE: timezones are found in /usr/share/zoneinfo
#   Note: if unset, the value in /etc/localtime is used unchanged
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.UTF-8"
DAEMON_LOCALE="no"
HARDWARECLOCK="UTC"
TIMEZONE="Asia/Tehran"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MODULES: Modules to load at boot-up. Blacklisting is no longer supported.
#   Replace every !module by an entry as on the following line in a file in
#   /etc/modprobe.d:
#     blacklist module
#   See "man modprobe.conf" for details.
#
MODULES=(wl vboxdrv)

# Udev settle timeout (default to 30)
UDEV_TIMEOUT=30

# Scan for FakeRAID (dmraid) Volumes at startup
USEDMRAID="no"

# Scan for BTRFS volumes at startup
USEBTRFS="no"

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="ilius-vostro3300"

# Use 'ip addr' or 'ls /sys/class/net/' to see all available interfaces.
#
# Wired network setup
#   - interface: name of device (required)
#   - address: IP address (leave blank for DHCP)
#   - netmask: subnet mask (ignored for DHCP) (optional, defaults to 255.255.255.0)
#   - broadcast: broadcast address (ignored for DHCP) (optional)
#   - gateway: default route (ignored for DHCP)
# 
# Static IP example
# interface=eth0
# address=192.168.0.2
# netmask=255.255.255.0
# broadcast=192.168.0.255
# gateway=192.168.0.1
#
# DHCP example
# interface=eth0
# address=
# netmask=
# gateway=

interface=
address=
netmask=
broadcast=
gateway=

# Setting this to "yes" will skip network shutdown.
# This is required if your root device is on NFS.
NETWORK_PERSIST="no"

# Enable these netcfg profiles at boot-up. These are useful if you happen to
# need more advanced network features than the simple network service
# supports, such as multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This requires the netcfg package
#
#NETWORKS=(main)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
# If something other takes care of your hardware clock (ntpd, dual-boot...)
# you should disable 'hwclock' here.
#
DAEMONS=(syslog-ng dbus wicd)

## REMOVED: netfs network crond hwclock 
## ADDED: dbus networkmanager sshd nfs-common bluetooth samba httpd postgresql IBSng starcal2d wicd
4

Ilius, I think I've come across this problem before.

  1. First try to set the system time correctly. (ntp/whatever)
  2. Then, run hwclock --systohc

This should reset your hwclock to the system time, and should be persistent across reboot.

would you let us know if it works out?

  • But it works with both having hwclock in DAEMONS and not having. Can you describe me what does hwclock do exactly? – saeedgnu Sep 26 '11 at 13:38
  • 1
    hwclock isn't a daemon. It's a utility that writes to the hardware clock register (I think) on your processor/motherboard. This register is kept ticking by the button battery when you power off your computer. Try a man hwclock to find out more. – brice Sep 26 '11 at 14:02
2

OUTDATED

The following solution was feasible for older, pre-systemd Arch Linux installations. I leave it here for historical reference.

OUTDATED

You've got HARDWARECLOCK set to UTC in your rc.conf. I think that's the culprit. If you're in dual boot situation with windows you should have it set to "localtime" (see arch installation docs IIRC).

Another cause of your problem could be messed startup scripts because arch should perform "--hctosys" and "--systohc" during startups/shutdowns.

In linux you have to differentiate between system clock (let's call it SC) and hardware clock (HC). They are separate but interconnected. Time in SC (real time) is calculated knowing how HC is set (local time or UTC) and what system's time zone is. In windows there's no calculation – HC value is SC value. So, if UTC differs from your local time, linux is set to treat HC as set to UTC and linux SC shows proper time, windows will show rubbish. If, conversely, windows' time is set correctly and linux treats HC as set to UTC then linux' SC shows time "shifted". The solution would be to make linux treat HC as set to local time (HARDWARECLOCK="localtime").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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