{
    "content": [
        {
            "type": "text",
            "text": "# hwclock (man)\n\n## NAME\n\nhwclock - time clocks utility\n\n## SYNOPSIS\n\nhwclock [function] [option...]\n\n## DESCRIPTION\n\nhwclock is an administration tool for the time clocks. It can: display the Hardware Clock\ntime; set the Hardware Clock to a specified time; set the Hardware Clock from the System\nClock; set the System Clock from the Hardware Clock; compensate for Hardware Clock drift;\ncorrect the System Clock timescale; set the kernel’s timezone, NTP timescale, and epoch\n(Alpha only); and predict future Hardware Clock values based on its drift rate.\n\n## TLDR\n\n> Read or change the hardware clock.\n\n- Display the current time as reported by the hardware clock:\n  `sudo hwclock`\n- Write the current software clock time to the hardware clock (sometimes used during system setup):\n  `sudo hwclock {{-w|--systohc}}`\n- Write the current hardware clock time to the software clock:\n  `sudo hwclock {{-s|--hctosys}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FUNCTIONS** (9 subsections)\n- **OPTIONS** (8 subsections)\n- **NOTES** (6 subsections)\n- **DATE-TIME CONFIGURATION** (4 subsections)\n- **EXIT STATUS**\n- **ENVIRONMENT**\n- **FILES**\n- **SEE ALSO**\n- **AUTHORS**\n- **REPORTING BUGS**\n- **AVAILABILITY**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "hwclock",
        "section": "",
        "mode": "man",
        "summary": "hwclock - time clocks utility",
        "synopsis": "hwclock [function] [option...]",
        "tldr_summary": "Read or change the hardware clock.",
        "tldr_examples": [
            {
                "description": "Display the current time as reported by the hardware clock",
                "command": "sudo hwclock"
            },
            {
                "description": "Write the current software clock time to the hardware clock (sometimes used during system setup)",
                "command": "sudo hwclock {{-w|--systohc}}"
            },
            {
                "description": "Write the current hardware clock time to the software clock",
                "command": "sudo hwclock {{-s|--hctosys}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "-D",
                "long": "--debug",
                "arg": null,
                "description": "Use --verbose. The --debug option has been deprecated and may be repurposed or removed in a future release."
            },
            {
                "flag": "",
                "long": "--directisa",
                "arg": null,
                "description": "This option is meaningful for ISA compatible machines in the x86 and x8664 family. For other machines, it has no effect. This option tells hwclock to use explicit I/O instructions to access the Hardware Clock. Without this option, hwclock will use the rtc device file, which it assumes to be driven by the Linux RTC device driver. As of v2.26 it will no longer automatically use directisa when the rtc driver is unavailable; this was causing an unsafe condition that could allow two processes to access the Hardware Clock at the same time. Direct hardware access from userspace should only be used for testing, troubleshooting, and as a last resort when all other methods fail. See the --rtc option. --epoch=year This option is required when using the --setepoch function. The minimum year value is 1900. The maximum is system dependent (ULONGMAX - 1)."
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "Override hwclock's default rtc device file name. Otherwise it will use the first one found in this order: /dev/rtc0, /dev/rtc, /dev/misc/rtc. For IA-64: /dev/efirtc /dev/misc/efirtc"
            },
            {
                "flag": "-u",
                "long": "--utc",
                "arg": null,
                "description": "Indicate which timescale the Hardware Clock is set to. The Hardware Clock may be configured to use either the UTC or the local timescale, but nothing in the clock itself says which alternative is being used. The --localtime or --utc options give this information to the hwclock command. If you specify the wrong one (or specify neither and take a wrong default), both setting and reading the Hardware Clock will be incorrect. If you specify neither --utc nor --localtime then the one last given with a set function (--set, --systohc, or --adjust), as recorded in /etc/adjtime, will be used. If the adjtime file doesn’t exist, the default is UTC. Note: daylight saving time changes may be inconsistent when the Hardware Clock is kept in local time. See the discussion below, under LOCAL vs UTC."
            },
            {
                "flag": "",
                "long": "--noadjfile",
                "arg": null,
                "description": "Disable the facilities provided by /etc/adjtime. hwclock will not read nor write to that file with this option. Either --utc or --localtime must be specified when using this option."
            },
            {
                "flag": "",
                "long": "--test",
                "arg": null,
                "description": "Do not actually change anything on the system, that is, the Clocks or /etc/adjtime (--verbose is implicit with this option)."
            },
            {
                "flag": "",
                "long": "--update-drift",
                "arg": null,
                "description": "Update the Hardware Clock’s drift factor in /etc/adjtime. It can only be used with --set or --systohc. A minimum four hour period between settings is required. This is to avoid invalid calculations. The longer the period, the more precise the resulting drift factor will be. This option was added in v2.26, because it is typical for systems to call hwclock --systohc at shutdown; with the old behavior this would automatically (re)calculate the drift factor which caused several problems: • When using NTP with an '11 minute mode' kernel the drift factor would be clobbered to near zero. • It would not allow the use of 'cold' drift correction. With most configurations using 'cold' drift will yield favorable results. Cold, means when the machine is turned off which can have a significant impact on the drift factor. • (Re)calculating drift factor on every shutdown delivers suboptimal results. For example, if ephemeral conditions cause the machine to be abnormally hot the drift factor calculation would be out of range. • Significantly increased system shutdown times (as of v2.31 when not using --update-drift the RTC is not read). Having hwclock calculate the drift factor is a good starting point, but for optimal results it will likely need to be adjusted by directly editing the /etc/adjtime file. For most configurations once a machine’s optimal drift factor is crafted it should not need to be changed. Therefore, the old behavior to automatically (re)calculate drift was changed and now requires this option to be used. See the discussion below, under The Adjust Function. This option requires reading the Hardware Clock before setting it. If it cannot be read, then this option will cause the set functions to fail. This can happen, for example, if the Hardware Clock is corrupted by a power failure. In that case, the clock must first be set without this option. Despite it not working, the resulting drift correction factor would be invalid anyway."
            },
            {
                "flag": "-v",
                "long": "--verbose",
                "arg": null,
                "description": "Display more details about what hwclock is doing internally."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "date",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/date/1/json"
            },
            {
                "name": "adjtimex",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/adjtimex/8/json"
            },
            {
                "name": "gettimeofday",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/gettimeofday/2/json"
            },
            {
                "name": "settimeofday",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/settimeofday/2/json"
            },
            {
                "name": "crontab",
                "section": "1p",
                "url": "https://www.chedong.com/phpMan.php/man/crontab/1p/json"
            },
            {
                "name": "tzset",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/tzset/3/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "-a, --adjust",
                        "lines": 25,
                        "flag": "-a",
                        "long": "--adjust"
                    },
                    {
                        "name": "--predict",
                        "lines": 8,
                        "long": "--predict"
                    },
                    {
                        "name": "-r --show --get",
                        "lines": 11,
                        "flag": "-r",
                        "long": "--get"
                    },
                    {
                        "name": "-s --hctosys",
                        "lines": 50,
                        "flag": "-s",
                        "long": "--hctosys"
                    },
                    {
                        "name": "--set",
                        "lines": 4,
                        "long": "--set"
                    },
                    {
                        "name": "--systz",
                        "lines": 20,
                        "long": "--systz"
                    },
                    {
                        "name": "-w --systohc",
                        "lines": 4,
                        "flag": "-w",
                        "long": "--systohc"
                    },
                    {
                        "name": "-V --version",
                        "lines": 2,
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 30,
                "subsections": [
                    {
                        "name": "-D --debug",
                        "lines": 3,
                        "flag": "-D",
                        "long": "--debug"
                    },
                    {
                        "name": "--directisa",
                        "lines": 13,
                        "long": "--directisa"
                    },
                    {
                        "name": "-f --rtc=",
                        "lines": 4,
                        "flag": "-f"
                    },
                    {
                        "name": "-l --localtime -u --utc",
                        "lines": 15,
                        "flag": "-u",
                        "long": "--utc"
                    },
                    {
                        "name": "--noadjfile",
                        "lines": 4,
                        "long": "--noadjfile"
                    },
                    {
                        "name": "--test",
                        "lines": 3,
                        "long": "--test"
                    },
                    {
                        "name": "--update-drift",
                        "lines": 36,
                        "long": "--update-drift"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 2,
                        "flag": "-v",
                        "long": "--verbose"
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Clocks in a Linux System",
                        "lines": 55
                    },
                    {
                        "name": "Hardware Clock Access Methods",
                        "lines": 19
                    },
                    {
                        "name": "The Adjust Function",
                        "lines": 37
                    },
                    {
                        "name": "The Adjtime File",
                        "lines": 21
                    },
                    {
                        "name": "Automatic Hardware Clock Synchronization by the Kernel",
                        "lines": 32
                    },
                    {
                        "name": "ISA Hardware Clock Century value",
                        "lines": 12
                    }
                ]
            },
            {
                "name": "DATE-TIME CONFIGURATION",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Keeping Time without External Synchronization",
                        "lines": 56
                    },
                    {
                        "name": "Steps to calculate cold drift:",
                        "lines": 27
                    },
                    {
                        "name": "LOCAL vs UTC",
                        "lines": 26
                    },
                    {
                        "name": "POSIX vs 'RIGHT'",
                        "lines": 34
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "hwclock - time clocks utility\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "hwclock [function] [option...]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "hwclock is an administration tool for the time clocks. It can: display the Hardware Clock\ntime; set the Hardware Clock to a specified time; set the Hardware Clock from the System\nClock; set the System Clock from the Hardware Clock; compensate for Hardware Clock drift;\ncorrect the System Clock timescale; set the kernel’s timezone, NTP timescale, and epoch\n(Alpha only); and predict future Hardware Clock values based on its drift rate.\n\nSince v2.26 important changes were made to the --hctosys function and the --directisa option,\nand a new option --update-drift was added. See their respective descriptions below.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "The following functions are mutually exclusive, only one can be given at a time. If none is\ngiven, the default is --show.\n",
                "subsections": [
                    {
                        "name": "-a, --adjust",
                        "content": "Add or subtract time from the Hardware Clock to account for systematic drift since the\nlast time the clock was set or adjusted. See the discussion below, under The Adjust\nFunction.\n\n--getepoch; --setepoch\nThese functions are for Alpha machines only, and are only available through the Linux\nkernel RTC driver.\n\nThey are used to read and set the kernel’s Hardware Clock epoch value. Epoch is the\nnumber of years into AD to which a zero year value in the Hardware Clock refers. For\nexample, if the machine’s BIOS sets the year counter in the Hardware Clock to contain the\nnumber of full years since 1952, then the kernel’s Hardware Clock epoch value must be\n1952.\n\nThe --setepoch function requires using the --epoch option to specify the year. For\nexample:\n\nhwclock --setepoch --epoch=1952\n\nThe RTC driver attempts to guess the correct epoch value, so setting it may not be\nrequired.\n\nThis epoch value is used whenever hwclock reads or sets the Hardware Clock on an Alpha\nmachine. For ISA machines the kernel uses the fixed Hardware Clock epoch of 1900.\n",
                        "flag": "-a",
                        "long": "--adjust"
                    },
                    {
                        "name": "--predict",
                        "content": "Predict what the Hardware Clock will read in the future based upon the time given by the\n--date option and the information in /etc/adjtime. This is useful, for example, to\naccount for drift when setting a Hardware Clock wakeup (aka alarm). See rtcwake(8).\n\nDo not use this function if the Hardware Clock is being modified by anything other than\nthe current operating system’s hwclock command, such as '11 minute mode' or from\ndual-booting another OS.\n",
                        "long": "--predict"
                    },
                    {
                        "name": "-r --show --get",
                        "content": "Read the Hardware Clock and print its time to standard output in the ISO 8601 format. The\ntime shown is always in local time, even if you keep your Hardware Clock in UTC. See the\n--localtime option.\n\nShowing the Hardware Clock time is the default when no function is specified.\n\nThe --get function also applies drift correction to the time read, based upon the\ninformation in /etc/adjtime. Do not use this function if the Hardware Clock is being\nmodified by anything other than the current operating system’s hwclock command, such as\n'11 minute mode' or from dual-booting another OS.\n",
                        "flag": "-r",
                        "long": "--get"
                    },
                    {
                        "name": "-s --hctosys",
                        "content": "Set the System Clock from the Hardware Clock. The time read from the Hardware Clock is\ncompensated to account for systematic drift before using it to set the System Clock. See\nthe discussion below, under The Adjust Function.\n\nThe System Clock must be kept in the UTC timescale for date-time applications to work\ncorrectly in conjunction with the timezone configured for the system. If the Hardware\nClock is kept in local time then the time read from it must be shifted to the UTC\ntimescale before using it to set the System Clock. The --hctosys function does this based\nupon the information in the /etc/adjtime file or the command line arguments --localtime\nand --utc. Note: no daylight saving adjustment is made. See the discussion below, under\nLOCAL vs UTC.\n\nThe kernel also keeps a timezone value, the --hctosys function sets it to the timezone\nconfigured for the system. The system timezone is configured by the TZ environment\nvariable or the /etc/localtime file, as tzset(3) would interpret them. The obsolete\ntzdsttime field of the kernel’s timezone value is set to zero. (For details on what this\nfield used to mean, see settimeofday(2).)\n\nWhen used in a startup script, making the --hctosys function the first caller of\nsettimeofday(2) from boot, it will set the NTP '11 minute mode' timescale via the\npersistentclockislocal kernel variable. If the Hardware Clock’s timescale\nconfiguration is changed then a reboot is required to inform the kernel. See the\ndiscussion below, under Automatic Hardware Clock Synchronization by the Kernel.\n\nThis is a good function to use in one of the system startup scripts before the file\nsystems are mounted read/write.\n\nThis function should never be used on a running system. Jumping system time will cause\nproblems, such as corrupted filesystem timestamps. Also, if something has changed the\nHardware Clock, like NTP’s '11 minute mode', then --hctosys will set the time incorrectly\nby including drift compensation.\n\nDrift compensation can be inhibited by setting the drift factor in /etc/adjtime to zero.\nThis setting will be persistent as long as the --update-drift option is not used with\n--systohc at shutdown (or anywhere else). Another way to inhibit this is by using the\n--noadjfile option when calling the --hctosys function. A third method is to delete the\n/etc/adjtime file. Hwclock will then default to using the UTC timescale for the Hardware\nClock. If the Hardware Clock is ticking local time it will need to be defined in the\nfile. This can be done by calling hwclock --localtime --adjust; when the file is not\npresent this command will not actually adjust the Clock, but it will create the file with\nlocal time configured, and a drift factor of zero.\n\nA condition under which inhibiting hwclock's drift correction may be desired is when\ndual-booting multiple operating systems. If while this instance of Linux is stopped,\nanother OS changes the Hardware Clock’s value, then when this instance is started again\nthe drift correction applied will be incorrect.\n\nFor hwclock's drift correction to work properly it is imperative that nothing changes the\nHardware Clock while its Linux instance is not running.\n",
                        "flag": "-s",
                        "long": "--hctosys"
                    },
                    {
                        "name": "--set",
                        "content": "Set the Hardware Clock to the time given by the --date option, and update the timestamps\nin /etc/adjtime. With the --update-drift option also (re)calculate the drift factor. Try\nit without the option if --set fails. See --update-drift below.\n",
                        "long": "--set"
                    },
                    {
                        "name": "--systz",
                        "content": "This is an alternate to the --hctosys function that does not read the Hardware Clock nor\nset the System Clock; consequently there is not any drift correction. It is intended to\nbe used in a startup script on systems with kernels above version 2.6 where you know the\nSystem Clock has been set from the Hardware Clock by the kernel during boot.\n\nIt does the following things that are detailed above in the --hctosys function:\n\n•   Corrects the System Clock timescale to UTC as needed. Only instead of accomplishing\nthis by setting the System Clock, hwclock simply informs the kernel and it handles\nthe change.\n\n•   Sets the kernel’s NTP '11 minute mode' timescale.\n\n•   Sets the kernel’s timezone.\n\nThe first two are only available on the first call of settimeofday(2) after boot.\nConsequently this option only makes sense when used in a startup script. If the Hardware\nClocks timescale configuration is changed then a reboot would be required to inform the\nkernel.\n",
                        "long": "--systz"
                    },
                    {
                        "name": "-w --systohc",
                        "content": "Set the Hardware Clock from the System Clock, and update the timestamps in /etc/adjtime.\nWith the --update-drift option also (re)calculate the drift factor. Try it without the\noption if --systohc fails. See --update-drift below.\n",
                        "flag": "-w",
                        "long": "--systohc"
                    },
                    {
                        "name": "-V --version",
                        "content": "Display version information and exit.\n",
                        "flag": "-V",
                        "long": "--version"
                    },
                    {
                        "name": "-h --help",
                        "content": "Display help text and exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    }
                ]
            },
            "OPTIONS": {
                "content": "--adjfile=filename\nOverride the default /etc/adjtime file path.\n\n--date=datestring\nThis option must be used with the --set or --predict functions, otherwise it is ignored.\n\nhwclock --set --date='16:45'\n\nhwclock --predict --date='2525-08-14 07:11:05'\n\nThe argument must be in local time, even if you keep your Hardware Clock in UTC. See the\n--localtime option. Therefore, the argument should not include any timezone information.\nIt also should not be a relative time like \"+5 minutes\", because hwclock's precision\ndepends upon correlation between the argument’s value and when the enter key is pressed.\nFractional seconds are silently dropped. This option is capable of understanding many\ntime and date formats, but the previous parameters should be observed.\n\n--delay=seconds\nThis option can be used to overwrite the internally used delay when setting the clock\ntime. The default is 0.5 (500ms) for rtccmos, for another RTC types the delay is 0. If\nRTC type is impossible to determine (from sysfs) then it defaults also to 0.5 to be\nbackwardly compatible.\n\nThe 500ms default is based on commonly used MC146818A-compatible (x86) hardware clock.\nThis Hardware Clock can only be set to any integer time plus one half second. The integer\ntime is required because there is no interface to set or get a fractional second. The\nadditional half second delay is because the Hardware Clock updates to the following\nsecond precisely 500 ms after setting the new time. Unfortunately, this behavior is\nhardware specific and in same cases another delay is required.\n",
                "subsections": [
                    {
                        "name": "-D --debug",
                        "content": "Use --verbose. The --debug option has been deprecated and may be repurposed or removed in\na future release.\n",
                        "flag": "-D",
                        "long": "--debug"
                    },
                    {
                        "name": "--directisa",
                        "content": "This option is meaningful for ISA compatible machines in the x86 and x8664 family. For\nother machines, it has no effect. This option tells hwclock to use explicit I/O\ninstructions to access the Hardware Clock. Without this option, hwclock will use the rtc\ndevice file, which it assumes to be driven by the Linux RTC device driver. As of v2.26 it\nwill no longer automatically use directisa when the rtc driver is unavailable; this was\ncausing an unsafe condition that could allow two processes to access the Hardware Clock\nat the same time. Direct hardware access from userspace should only be used for testing,\ntroubleshooting, and as a last resort when all other methods fail. See the --rtc option.\n\n--epoch=year\nThis option is required when using the --setepoch function. The minimum year value is\n1900. The maximum is system dependent (ULONGMAX - 1).\n",
                        "long": "--directisa"
                    },
                    {
                        "name": "-f --rtc=",
                        "content": "Override hwclock's default rtc device file name. Otherwise it will use the first one\nfound in this order: /dev/rtc0, /dev/rtc, /dev/misc/rtc. For IA-64: /dev/efirtc\n/dev/misc/efirtc\n",
                        "flag": "-f"
                    },
                    {
                        "name": "-l --localtime -u --utc",
                        "content": "Indicate which timescale the Hardware Clock is set to.\n\nThe Hardware Clock may be configured to use either the UTC or the local timescale, but\nnothing in the clock itself says which alternative is being used. The --localtime or\n--utc options give this information to the hwclock command. If you specify the wrong one\n(or specify neither and take a wrong default), both setting and reading the Hardware\nClock will be incorrect.\n\nIf you specify neither --utc nor --localtime then the one last given with a set function\n(--set, --systohc, or --adjust), as recorded in /etc/adjtime, will be used. If the\nadjtime file doesn’t exist, the default is UTC.\n\nNote: daylight saving time changes may be inconsistent when the Hardware Clock is kept in\nlocal time. See the discussion below, under LOCAL vs UTC.\n",
                        "flag": "-u",
                        "long": "--utc"
                    },
                    {
                        "name": "--noadjfile",
                        "content": "Disable the facilities provided by /etc/adjtime. hwclock will not read nor write to that\nfile with this option. Either --utc or --localtime must be specified when using this\noption.\n",
                        "long": "--noadjfile"
                    },
                    {
                        "name": "--test",
                        "content": "Do not actually change anything on the system, that is, the Clocks or /etc/adjtime\n(--verbose is implicit with this option).\n",
                        "long": "--test"
                    },
                    {
                        "name": "--update-drift",
                        "content": "Update the Hardware Clock’s drift factor in /etc/adjtime. It can only be used with --set\nor --systohc.\n\nA minimum four hour period between settings is required. This is to avoid invalid\ncalculations. The longer the period, the more precise the resulting drift factor will be.\n\nThis option was added in v2.26, because it is typical for systems to call hwclock\n--systohc at shutdown; with the old behavior this would automatically (re)calculate the\ndrift factor which caused several problems:\n\n•   When using NTP with an '11 minute mode' kernel the drift factor would be clobbered to\nnear zero.\n\n•   It would not allow the use of 'cold' drift correction. With most configurations using\n'cold' drift will yield favorable results. Cold, means when the machine is turned off\nwhich can have a significant impact on the drift factor.\n\n•   (Re)calculating drift factor on every shutdown delivers suboptimal results. For\nexample, if ephemeral conditions cause the machine to be abnormally hot the drift\nfactor calculation would be out of range.\n\n•   Significantly increased system shutdown times (as of v2.31 when not using\n--update-drift the RTC is not read).\n\nHaving hwclock calculate the drift factor is a good starting point, but for optimal results\nit will likely need to be adjusted by directly editing the /etc/adjtime file. For most\nconfigurations once a machine’s optimal drift factor is crafted it should not need to be\nchanged. Therefore, the old behavior to automatically (re)calculate drift was changed and now\nrequires this option to be used. See the discussion below, under The Adjust Function.\n\nThis option requires reading the Hardware Clock before setting it. If it cannot be read, then\nthis option will cause the set functions to fail. This can happen, for example, if the\nHardware Clock is corrupted by a power failure. In that case, the clock must first be set\nwithout this option. Despite it not working, the resulting drift correction factor would be\ninvalid anyway.\n",
                        "long": "--update-drift"
                    },
                    {
                        "name": "-v --verbose",
                        "content": "Display more details about what hwclock is doing internally.\n",
                        "flag": "-v",
                        "long": "--verbose"
                    }
                ]
            },
            "NOTES": {
                "content": "",
                "subsections": [
                    {
                        "name": "Clocks in a Linux System",
                        "content": "There are two types of date-time clocks:\n\nThe Hardware Clock: This clock is an independent hardware device, with its own power domain\n(battery, capacitor, etc), that operates when the machine is powered off, or even unplugged.\n\nOn an ISA compatible system, this clock is specified as part of the ISA standard. A control\nprogram can read or set this clock only to a whole second, but it can also detect the edges\nof the 1 second clock ticks, so the clock actually has virtually infinite precision.\n\nThis clock is commonly called the hardware clock, the real time clock, the RTC, the BIOS\nclock, and the CMOS clock. Hardware Clock, in its capitalized form, was coined for use by\nhwclock. The Linux kernel also refers to it as the persistent clock.\n\nSome non-ISA systems have a few real time clocks with only one of them having its own power\ndomain. A very low power external I2C or SPI clock chip might be used with a backup battery\nas the hardware clock to initialize a more functional integrated real-time clock which is\nused for most other purposes.\n\nThe System Clock: This clock is part of the Linux kernel and is driven by a timer interrupt.\n(On an ISA machine, the timer interrupt is part of the ISA standard.) It has meaning only\nwhile Linux is running on the machine. The System Time is the number of seconds since\n00:00:00 January 1, 1970 UTC (or more succinctly, the number of seconds since 1969 UTC). The\nSystem Time is not an integer, though. It has virtually infinite precision.\n\nThe System Time is the time that matters. The Hardware Clock’s basic purpose is to keep time\nwhen Linux is not running so that the System Clock can be initialized from it at boot. Note\nthat in DOS, for which ISA was designed, the Hardware Clock is the only real time clock.\n\nIt is important that the System Time not have any discontinuities such as would happen if you\nused the date(1) program to set it while the system is running. You can, however, do whatever\nyou want to the Hardware Clock while the system is running, and the next time Linux starts\nup, it will do so with the adjusted time from the Hardware Clock. Note: currently this is not\npossible on most systems because hwclock --systohc is called at shutdown.\n\nThe Linux kernel’s timezone is set by hwclock. But don’t be misled — almost nobody cares what\ntimezone the kernel thinks it is in. Instead, programs that care about the timezone (perhaps\nbecause they want to display a local time for you) almost always use a more traditional\nmethod of determining the timezone: They use the TZ environment variable or the\n/etc/localtime file, as explained in the man page for tzset(3). However, some programs and\nfringe parts of the Linux kernel such as filesystems use the kernel’s timezone value. An\nexample is the vfat filesystem. If the kernel timezone value is wrong, the vfat filesystem\nwill report and set the wrong timestamps on files. Another example is the kernel’s NTP '11\nminute mode'. If the kernel’s timezone value and/or the persistentclockislocal variable\nare wrong, then the Hardware Clock will be set incorrectly by '11 minute mode'. See the\ndiscussion below, under Automatic Hardware Clock Synchronization by the Kernel.\n\nhwclock sets the kernel’s timezone to the value indicated by TZ or /etc/localtime with the\n--hctosys or --systz functions.\n\nThe kernel’s timezone value actually consists of two parts: 1) a field tzminuteswest\nindicating how many minutes local time (not adjusted for DST) lags behind UTC, and 2) a field\ntzdsttime indicating the type of Daylight Savings Time (DST) convention that is in effect in\nthe locality at the present time. This second field is not used under Linux and is always\nzero. See also settimeofday(2).\n"
                    },
                    {
                        "name": "Hardware Clock Access Methods",
                        "content": "hwclock uses many different ways to get and set Hardware Clock values. The most normal way is\nto do I/O to the rtc device special file, which is presumed to be driven by the rtc device\ndriver. Also, Linux systems using the rtc framework with udev, are capable of supporting\nmultiple Hardware Clocks. This may bring about the need to override the default rtc device by\nspecifying one with the --rtc option.\n\nHowever, this method is not always available as older systems do not have an rtc driver. On\nthese systems, the method of accessing the Hardware Clock depends on the system hardware.\n\nOn an ISA compatible system, hwclock can directly access the \"CMOS memory\" registers that\nconstitute the clock, by doing I/O to Ports 0x70 and 0x71. It does this with actual I/O\ninstructions and consequently can only do it if running with superuser effective userid. This\nmethod may be used by specifying the --directisa option.\n\nThis is a really poor method of accessing the clock, for all the reasons that userspace\nprograms are generally not supposed to do direct I/O and disable interrupts. hwclock provides\nit for testing, troubleshooting, and because it may be the only method available on ISA\nsystems which do not have a working rtc device driver.\n"
                    },
                    {
                        "name": "The Adjust Function",
                        "content": "The Hardware Clock is usually not very accurate. However, much of its inaccuracy is\ncompletely predictable - it gains or loses the same amount of time every day. This is called\nsystematic drift. hwclock's --adjust function lets you apply systematic drift corrections to\nthe Hardware Clock.\n\nIt works like this: hwclock keeps a file, /etc/adjtime, that keeps some historical\ninformation. This is called the adjtime file.\n\nSuppose you start with no adjtime file. You issue a hwclock --set command to set the Hardware\nClock to the true current time. hwclock creates the adjtime file and records in it the\ncurrent time as the last time the clock was calibrated. Five days later, the clock has gained\n10 seconds, so you issue a hwclock --set --update-drift command to set it back 10 seconds.\nhwclock updates the adjtime file to show the current time as the last time the clock was\ncalibrated, and records 2 seconds per day as the systematic drift rate. 24 hours go by, and\nthen you issue a hwclock --adjust command. hwclock consults the adjtime file and sees that\nthe clock gains 2 seconds per day when left alone and that it has been left alone for exactly\none day. So it subtracts 2 seconds from the Hardware Clock. It then records the current time\nas the last time the clock was adjusted. Another 24 hours go by and you issue another hwclock\n--adjust. hwclock does the same thing: subtracts 2 seconds and updates the adjtime file with\nthe current time as the last time the clock was adjusted.\n\nWhen you use the --update-drift option with --set or --systohc, the systematic drift rate is\n(re)calculated by comparing the fully drift corrected current Hardware Clock time with the\nnew set time, from that it derives the 24 hour drift rate based on the last calibrated\ntimestamp from the adjtime file. This updated drift factor is then saved in /etc/adjtime.\n\nA small amount of error creeps in when the Hardware Clock is set, so --adjust refrains from\nmaking any adjustment that is less than 1 second. Later on, when you request an adjustment\nagain, the accumulated drift will be more than 1 second and --adjust will make the adjustment\nincluding any fractional amount.\n\nhwclock --hctosys also uses the adjtime file data to compensate the value read from the\nHardware Clock before using it to set the System Clock. It does not share the 1 second\nlimitation of --adjust, and will correct sub-second drift values immediately. It does not\nchange the Hardware Clock time nor the adjtime file. This may eliminate the need to use\n--adjust, unless something else on the system needs the Hardware Clock to be compensated.\n"
                    },
                    {
                        "name": "The Adjtime File",
                        "content": "While named for its historical purpose of controlling adjustments only, it actually contains\nother information used by hwclock from one invocation to the next.\n\nThe format of the adjtime file is, in ASCII:\n\nLine 1: Three numbers, separated by blanks: 1) the systematic drift rate in seconds per day,\nfloating point decimal; 2) the resulting number of seconds since 1969 UTC of most recent\nadjustment or calibration, decimal integer; 3) zero (for compatibility with clock(8)) as a\nfloating point decimal.\n\nLine 2: One number: the resulting number of seconds since 1969 UTC of most recent\ncalibration. Zero if there has been no calibration yet or it is known that any previous\ncalibration is moot (for example, because the Hardware Clock has been found, since that\ncalibration, not to contain a valid time). This is a decimal integer.\n\nLine 3: \"UTC\" or \"LOCAL\". Tells whether the Hardware Clock is set to Coordinated Universal\nTime or local time. You can always override this value with options on the hwclock command\nline.\n\nYou can use an adjtime file that was previously used with the clock(8) program with hwclock.\n"
                    },
                    {
                        "name": "Automatic Hardware Clock Synchronization by the Kernel",
                        "content": "You should be aware of another way that the Hardware Clock is kept synchronized in some\nsystems. The Linux kernel has a mode wherein it copies the System Time to the Hardware Clock\nevery 11 minutes. This mode is a compile time option, so not all kernels will have this\ncapability. This is a good mode to use when you are using something sophisticated like NTP to\nkeep your System Clock synchronized. (NTP is a way to keep your System Time synchronized\neither to a time server somewhere on the network or to a radio clock hooked up to your\nsystem. See RFC 1305.)\n\nIf the kernel is compiled with the '11 minute mode' option it will be active when the\nkernel’s clock discipline is in a synchronized state. When in this state, bit 6 (the bit that\nis set in the mask 0x0040) of the kernel’s timestatus variable is unset. This value is\noutput as the 'status' line of the adjtimex --print or ntptime commands.\n\nIt takes an outside influence, like the NTP daemon to put the kernel’s clock discipline into\na synchronized state, and therefore turn on '11 minute mode'. It can be turned off by running\nanything that sets the System Clock the old fashioned way, including hwclock --hctosys.\nHowever, if the NTP daemon is still running, it will turn '11 minute mode' back on again the\nnext time it synchronizes the System Clock.\n\nIf your system runs with '11 minute mode' on, it may need to use either --hctosys or --systz\nin a startup script, especially if the Hardware Clock is configured to use the local\ntimescale. Unless the kernel is informed of what timescale the Hardware Clock is using, it\nmay clobber it with the wrong one. The kernel uses UTC by default.\n\nThe first userspace command to set the System Clock informs the kernel what timescale the\nHardware Clock is using. This happens via the persistentclockislocal kernel variable. If\n--hctosys or --systz is the first, it will set this variable according to the adjtime file or\nthe appropriate command-line argument. Note that when using this capability and the Hardware\nClock timescale configuration is changed, then a reboot is required to notify the kernel.\n\nhwclock --adjust should not be used with NTP '11 minute mode'.\n"
                    },
                    {
                        "name": "ISA Hardware Clock Century value",
                        "content": "There is some sort of standard that defines CMOS memory Byte 50 on an ISA machine as an\nindicator of what century it is. hwclock does not use or set that byte because there are some\nmachines that don’t define the byte that way, and it really isn’t necessary anyway, since the\nyear-of-century does a good job of implying which century it is.\n\nIf you have a bona fide use for a CMOS century byte, contact the hwclock maintainer; an\noption may be appropriate.\n\nNote that this section is only relevant when you are using the \"direct ISA\" method of\naccessing the Hardware Clock. ACPI provides a standard way to access century values, when\nthey are supported by the hardware.\n"
                    }
                ]
            },
            "DATE-TIME CONFIGURATION": {
                "content": "",
                "subsections": [
                    {
                        "name": "Keeping Time without External Synchronization",
                        "content": "This discussion is based on the following conditions:\n\n•   Nothing is running that alters the date-time clocks, such as NTP daemon or a cron job.\"\n\n•   The system timezone is configured for the correct local time. See below, under POSIX vs\n'RIGHT'.\n\n•   Early during startup the following are called, in this order: adjtimex --tick value\n--frequency value hwclock --hctosys\n\n•   During shutdown the following is called: hwclock --systohc\n\n•   Systems without adjtimex may use ntptime.\n\nWhether maintaining precision time with NTP daemon or not, it makes sense to configure the\nsystem to keep reasonably good date-time on its own.\n\nThe first step in making that happen is having a clear understanding of the big picture.\nThere are two completely separate hardware devices running at their own speed and drifting\naway from the 'correct' time at their own rates. The methods and software for drift\ncorrection are different for each of them. However, most systems are configured to exchange\nvalues between these two clocks at startup and shutdown. Now the individual device’s time\nkeeping errors are transferred back and forth between each other. Attempt to configure drift\ncorrection for only one of them, and the other’s drift will be overlaid upon it.\n\nThis problem can be avoided when configuring drift correction for the System Clock by simply\nnot shutting down the machine. This, plus the fact that all of hwclock's precision (including\ncalculating drift factors) depends upon the System Clock’s rate being correct, means that\nconfiguration of the System Clock should be done first.\n\nThe System Clock drift is corrected with the adjtimex(8) command’s --tick and --frequency\noptions. These two work together: tick is the coarse adjustment and frequency is the fine\nadjustment. (For systems that do not have an adjtimex package, ntptime -f ppm may be used\ninstead.)\n\nSome Linux distributions attempt to automatically calculate the System Clock drift with\nadjtimex's compare operation. Trying to correct one drifting clock by using another drifting\nclock as a reference is akin to a dog trying to catch its own tail. Success may happen\neventually, but great effort and frustration will likely precede it. This automation may\nyield an improvement over no configuration, but expecting optimum results would be in error.\nA better choice for manual configuration would be adjtimex's --log options.\n\nIt may be more effective to simply track the System Clock drift with sntp, or date -Ins and a\nprecision timepiece, and then calculate the correction manually.\n\nAfter setting the tick and frequency values, continue to test and refine the adjustments\nuntil the System Clock keeps good time. See adjtimex(2) for more information and the example\ndemonstrating manual drift calculations.\n\nOnce the System Clock is ticking smoothly, move on to the Hardware Clock.\n\nAs a rule, cold drift will work best for most use cases. This should be true even for 24/7\nmachines whose normal downtime consists of a reboot. In that case the drift factor value\nmakes little difference. But on the rare occasion that the machine is shut down for an\nextended period, then cold drift should yield better results.\n"
                    },
                    {
                        "name": "Steps to calculate cold drift:",
                        "content": "1\nEnsure that NTP daemon will not be launched at startup.\n\n2\nThe System Clock time must be correct at shutdown!\n\n3\nShut down the system.\n\n4\nLet an extended period pass without changing the Hardware Clock.\n\n5\nStart the system.\n\n6\nImmediately use hwclock to set the correct time, adding the --update-drift option.\n\nNote: if step 6 uses --systohc, then the System Clock must be set correctly (step 6a) just\nbefore doing so.\n\nHaving hwclock calculate the drift factor is a good starting point, but for optimal results\nit will likely need to be adjusted by directly editing the /etc/adjtime file. Continue to\ntest and refine the drift factor until the Hardware Clock is corrected properly at startup.\nTo check this, first make sure that the System Time is correct before shutdown and then use\nsntp, or date -Ins and a precision timepiece, immediately after startup.\n"
                    },
                    {
                        "name": "LOCAL vs UTC",
                        "content": "Keeping the Hardware Clock in a local timescale causes inconsistent daylight saving time\nresults:\n\n•   If Linux is running during a daylight saving time change, the time written to the\nHardware Clock will be adjusted for the change.\n\n•   If Linux is NOT running during a daylight saving time change, the time read from the\nHardware Clock will NOT be adjusted for the change.\n\nThe Hardware Clock on an ISA compatible system keeps only a date and time, it has no concept\nof timezone nor daylight saving. Therefore, when hwclock is told that it is in local time, it\nassumes it is in the 'correct' local time and makes no adjustments to the time read from it.\n\nLinux handles daylight saving time changes transparently only when the Hardware Clock is kept\nin the UTC timescale. Doing so is made easy for system administrators as hwclock uses local\ntime for its output and as the argument to the --date option.\n\nPOSIX systems, like Linux, are designed to have the System Clock operate in the UTC\ntimescale. The Hardware Clock’s purpose is to initialize the System Clock, so also keeping it\nin UTC makes sense.\n\nLinux does, however, attempt to accommodate the Hardware Clock being in the local timescale.\nThis is primarily for dual-booting with older versions of MS Windows. From Windows 7 on, the\nRealTimeIsUniversal registry key is supposed to be working properly so that its Hardware\nClock can be kept in UTC.\n"
                    },
                    {
                        "name": "POSIX vs 'RIGHT'",
                        "content": "A discussion on date-time configuration would be incomplete without addressing timezones,\nthis is mostly well covered by tzset(3). One area that seems to have no documentation is the\n'right' directory of the Time Zone Database, sometimes called tz or zoneinfo.\n\nThere are two separate databases in the zoneinfo system, posix and 'right'. 'Right' (now\nnamed zoneinfo-leaps) includes leap seconds and posix does not. To use the 'right' database\nthe System Clock must be set to (UTC + leap seconds), which is equivalent to (TAI - 10). This\nallows calculating the exact number of seconds between two dates that cross a leap second\nepoch. The System Clock is then converted to the correct civil time, including UTC, by using\nthe 'right' timezone files which subtract the leap seconds. Note: this configuration is\nconsidered experimental and is known to have issues.\n\nTo configure a system to use a particular database all of the files located in its directory\nmust be copied to the root of /usr/share/zoneinfo. Files are never used directly from the\nposix or 'right' subdirectories, e.g., TZ='right/Europe/Dublin'. This habit was becoming so\ncommon that the upstream zoneinfo project restructured the system’s file tree by moving the\nposix and 'right' subdirectories out of the zoneinfo directory and into sibling directories:\n\n/usr/share/zoneinfo, /usr/share/zoneinfo-posix, /usr/share/zoneinfo-leaps\n\nUnfortunately, some Linux distributions are changing it back to the old tree structure in\ntheir packages. So the problem of system administrators reaching into the 'right'\nsubdirectory persists. This causes the system timezone to be configured to include leap\nseconds while the zoneinfo database is still configured to exclude them. Then when an\napplication such as a World Clock needs the SouthPole timezone file; or an email MTA, or\nhwclock needs the UTC timezone file; they fetch it from the root of /usr/share/zoneinfo ,\nbecause that is what they are supposed to do. Those files exclude leap seconds, but the\nSystem Clock now includes them, causing an incorrect time conversion.\n\nAttempting to mix and match files from these separate databases will not work, because they\neach require the System Clock to use a different timescale. The zoneinfo database must be\nconfigured to use either posix or 'right', as described above, or by assigning a database\npath to the TZDIR environment variable.\n"
                    }
                ]
            },
            "EXIT STATUS": {
                "content": "One of the following exit values will be returned:\n\nEXITSUCCESS ('0' on POSIX systems)\nSuccessful program execution.\n\nEXITFAILURE ('1' on POSIX systems)\nThe operation failed or the command syntax was not valid.\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "TZ\nIf this variable is set its value takes precedence over the system configured timezone.\n\nTZDIR\nIf this variable is set its value takes precedence over the system configured timezone\ndatabase directory path.\n",
                "subsections": []
            },
            "FILES": {
                "content": "/etc/adjtime\nThe configuration and state file for hwclock.\n\n/etc/localtime\nThe system timezone file.\n\n/usr/share/zoneinfo/\nThe system timezone database directory.\n\nDevice files hwclock may try for Hardware Clock access: /dev/rtc0 /dev/rtc /dev/misc/rtc\n/dev/efirtc /dev/misc/efirtc\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "date(1), adjtimex(8), gettimeofday(2), settimeofday(2), crontab(1p), tzset(3)\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Written by Bryan Henderson <bryanh@giraffe-data.com>, September 1996, based on work done on\nthe clock(8) program by Charles Hedrick, Rob Hooft, and Harald Koenig. See the source code\nfor complete history and credits.\n",
                "subsections": []
            },
            "REPORTING BUGS": {
                "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
                "subsections": []
            },
            "AVAILABILITY": {
                "content": "The hwclock command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                   HWCLOCK(8)",
                "subsections": []
            }
        }
    }
}