1.\" Copyright (C) 1993-1998 by Andrey A. Chernov, Moscow, Russia. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd April 4, 1996 28.Dt ADJKERNTZ 8 29.Os FreeBSD 30.Sh NAME 31.Nm adjkerntz 32.Nd "adjust local time CMOS clock to reflect time zone changes and keep current timezone offset for the kernel" 33.Sh SYNOPSIS 34.Nm adjkerntz 35.Fl i 36.Nm adjkerntz 37.Fl a Op Fl s 38.Sh DESCRIPTION 39.Nm Adjkerntz 40maintains the proper relationship between the kernel clock, which 41is always set to UTC, and the CMOS clock, which may be set to local 42time. 43.Nm Adjkerntz 44also informs the kernel about machine timezone shifts to 45maintain proper timestamps for local time file systems such as the MS-DOS 46file system. The main purpose of this thing is not general fixing of 47initially broken MS-DOS file timestamp idea but keeping 48the same timestamps between 49.Bx Free 50MS-DOS file system 51and MS-DOS operating system installed on the same 52machine. 53If the file 54.Pa /etc/wall_cmos_clock 55exists, it means that CMOS clock keeps local time (MS-DOS and MS-Windows 56compatible mode). 57If that file does not exist, it means that the CMOS clock keeps UTC time. 58.Nm Adjkerntz 59passes this state to the 60.Pa machdep.wall_cmos_clock 61kernel variable. 62.Pp 63Adjustments may be needed at system startup and shutdown, and 64whenever a time zone change occurs. 65To handle these different situations, 66.Nm 67is invoked in two ways: 68.Bl -tag -width 4n 69.It Cm Fl i 70This form handles system startups and shutdowns. 71.Nm Adjkerntz 72is invoked with this option from 73.Pa /etc/rc 74on entry to multi-user mode, before any other daemons have been started. 75.Nm Adjkerntz 76puts itself into the background. 77Then, for a local time CMOS clock, 78.Nm 79reads the local time from it 80and sets the kernel clock to the corresponding UTC time. 81.Nm Adjkerntz 82also stores the local time zone offset into the 83.Pa machdep.adjkerntz 84kernel variable, for use by subsequent invocations of 85.Em "'adjkerntz -a'" 86and by local time file systems. 87.Pp 88For a local time CMOS clock 89.Em "'adjkerntz -i'" 90pauses, and remains inactive as a background daemon until it 91receives a SIGTERM. 92The SIGTERM will normally be sent by 93.Xr init 8 94when the system leaves multi-user mode (usually, because the system 95is being shut down). 96After receiving the SIGTERM, 97.Nm 98reads the UTC kernel clock and updates the CMOS clock, if necessary, 99to ensure that it reflects the current local time zone. 100Then 101.Nm 102exits. 103.It Cm Fl a Op Fl s 104This form is used to update the local time CMOS clock and kernel 105.Pa machdep.adjkerntz 106variable when time zone changes occur, 107e.g., when entering or leaving daylight savings time. 108.Nm Adjkerntz 109uses the kernel clock's UTC time, 110the previously stored 111time zone offset, and the changed time zone rule to 112calculate a new time zone offset. 113It stores the new offset into the 114.Pa machdep.adjkerntz 115kernel variable, and updates the wall CMOS clock to the new local time. 116If 117.Em "'adjkerntz -a'" 118was started at a nonexistent time (during a timezone change), it exits 119with a warning diagnostic unless the 120.Fl s 121option was used, in which case 122.Nm 123sleeps 30 minutes and tries again. 124.Pp 125This form should be invoked from root's 126.Xr crontab 5 127every half hour between midnight and 5am, when most modern time 128zone changes occur. 129Warning: don't use the 130.Fl s 131option in a 132.Xr crontab 5 133command line, or multiple 134.Em "'adjkerntz -a'" 135instances could conflict with each other. 136.El 137.Pp 138.Nm Adjkerntz 139clears the kernel timezone structure and makes the kernel clock run 140in the UTC time zone. 141Super-user privileges are required for all operations. 142.Sh ENVIRONMENT 143.Bl -tag -width Fl 144.It Ev TZ 145Time zone change rule, see 146.Xr tzset 3 ; 147not needed when 148.Xr tzsetup 8 149or 150.Xr zic 8 151is used. 152.Sh FILES 153.Bl -tag -width /etc/wall_cmos_clock -compact 154.It Pa /etc/localtime 155Current zoneinfo file, see 156.Xr tzsetup 8 157and 158.Xr zic 8 . 159.It Pa /etc/wall_cmos_clock 160Empty file. 161Its presence indicates that the machine's CMOS clock is set to local 162time, while its absence indicates a UTC CMOS clock. 163.El 164.Sh SEE ALSO 165.Xr tzset 3 , 166.Xr crontab 5 , 167.Xr mount_msdos 8 , 168.Xr rc 8 , 169.Xr sysctl 8 , 170.Xr tzsetup 8 , 171.Xr zic 8 172.Sh DIAGNOSTICS 173No diagnostics. 174If an error occurs, 175.Nm 176logs an error message via 177.Xr syslog 3 178and exits with a nonzero return code. 179.Sh AUTHORS 180.An Andrey A. Chernov Aq ache@astral.msk.su 181.Sh HISTORY 182The 183.Nm 184command appeared in 185.Fx 1.0 . 186