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