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