1.\" Copyright (C) 1993-1996 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.Dd April 4, 1996 26.Dt ADJKERNTZ 8 27.Os FreeBSD 28.Sh NAME 29.Nm adjkerntz 30.Nd "adjust local time CMOS clock to reflect time zone changes and keep current timezone offset for the kernel" 31.Sh SYNOPSIS 32.Nm adjkerntz 33.Fl i 34.Nm adjkerntz 35.Fl a Op Fl s 36.Sh DESCRIPTION 37.Nm Adjkerntz 38maintains the proper relationship between the kernel clock, which 39is always set to UTC, and the CMOS clock, which may be set to local 40time. 41.Nm Adjkerntz 42also informs the kernel about machine timezone shifts to 43maintain proper timestamps for local time file systems such as the MS-DOS 44file system. The main purpose of this thing is not general fixing of 45initially broken MS-DOS file timestamp idea but keeping 46the same timestamps between FreeBSD MS-DOS file system 47and MS-DOS operating system installed on the same 48machine. 49If the file 50.Pa /etc/wall_cmos_clock 51exists, it means that CMOS clock keeps local time (MS-DOS and MS-Windows 52compatible mode). 53If that file does not exist, it means that the CMOS clock keeps UTC time. 54.Nm Adjkerntz 55passes this state to the 56.Pa machdep.wall_cmos_clock 57kernel variable. 58.Pp 59Adjustments may be needed at system startup and shutdown, and 60whenever a time zone change occurs. 61To handle these different situations, 62.Nm adjkerntz 63is invoked in two ways: 64.Bl -tag -width 4n 65.It Cm Fl i 66This form handles system startups and shutdowns. 67.Nm Adjkerntz 68is invoked with this option from 69.Pa /etc/rc 70on entry to multi-user mode, before any other daemons have been started. 71.Nm Adjkerntz 72puts itself into the background. 73Then, for a local time CMOS clock, 74.Nm adjkerntz 75reads the local time from it 76and sets the kernel clock to the corresponding UTC time. 77.Nm Adjkerntz 78also stores the local time zone offset into the 79.Pa machdep.adjkerntz 80kernel variable, for use by subsequent invocations of 81.Nm "'adjkerntz -a'" 82and by local time file systems. 83.Pp 84For a local time CMOS clock 85.Nm "'adjkerntz -i'" 86pauses, and remains inactive as a background daemon until it 87receives a SIGTERM. 88The SIGTERM will normally be sent by 89.Xr init 8 90when the system leaves multi-user mode (usually, because the system 91is being shut down). 92After receiving the SIGTERM, 93.Nm adjkerntz 94reads the UTC kernel clock and updates the CMOS clock, if necessary, 95to ensure that it reflects the current local time zone. 96Then 97.Nm adjkerntz 98exits. 99.It Cm Fl a Op Fl s 100This form is used to update the local time CMOS clock and kernel 101.Pa machdep.adjkerntz 102variable when time zone changes occur, 103e.g., when entering or leaving daylight savings time. 104.Nm Adjkerntz 105uses the kernel clock's UTC time, 106the previously stored 107time zone offset, and the changed time zone rule to 108calculate a new time zone offset. 109It stores the new offset into the 110.Pa machdep.adjkerntz 111kernel variable, and updates the wall CMOS clock to the new local time. 112If 113.Nm "'adjkerntz -a'" 114was started at a nonexistent time (during a timezone change), it exits 115with a warning diagnostic unless the 116.Fl s 117option was used, in which case 118.Nm adjkerntz 119sleeps 30 minutes and tries again. 120.Pp 121This form should be invoked from root's 122.Xr crontab 5 123every half hour between midnight and 4am, when most modern time 124zone changes occur. 125Warning: don't use the 126.Fl s 127option in a 128.Xr crontab 5 129command line, or multiple 130.Nm "'adjkerntz -a'" 131instances could conflict with each other. 132.El 133.Pp 134.Nm Adjkerntz 135clears the kernel timezone structure and makes the kernel clock run 136in the UTC time zone. 137Super-user privileges are required for all operations. 138.Sh ENVIRONMENT 139.Bl -tag -width Fl 140.It Ev TZ 141Time zone change rule, see 142.Xr tzset 3 ; 143not needed when 144.Xr tzsetup 8 145or 146.Xr zic 8 147is used. 148.Sh FILES 149.Bl -tag -width /etc/wall_cmos_clock -compact 150.It Pa /etc/localtime 151Current zoneinfo file, see 152.Xr tzsetup 8 153and 154.Xr zic 8 . 155.It Pa /etc/wall_cmos_clock 156Empty file. 157Its presence indicates that the machine's CMOS clock is set to local 158time, while its absence indicates a UTC CMOS clock. 159.Sh SEE ALSO 160.Xr tzset 3 , 161.Xr crontab 5 , 162.Xr rc 8 , 163.Xr mount_msdos 8 , 164.Xr sysctl 8 , 165.Xr tzsetup 8 , 166.Xr zic 8 . 167.Sh DIAGNOSTICS 168No diagnostics. 169If an error occurs, 170.Nm adjkerntz 171logs an error message via 172.Xr syslog 3 173and exits with a nonzero return code. 174.Sh AUTHOR 175Andrey A. Chernov <ache@astral.msk.su> 176.Sh HISTORY 177The 178.Nm adjkerntz 179command appeared in FreeBSD 1.0.1. 180