$ apt-cache show fake-hwclock
Maintainer: Steve McIntyre <email@example.com>
Depends: init-system-helpers (>= 1.18~)
Suggests: cron | cron-daemon, ntp
Description: Save/restore system clock on machines without working RTC hardware
Some machines don't have a working realtime clock (RTC) unit, or no
driver for the hardware that does exist. fake-hwclock is a simple set
of scripts to save the kernel's current clock periodically (including
at shutdown) and restore it at boot so that the system clock keeps at
least close to realtime. This will stop some of the problems that may
be caused by a system believing it has travelled in time back to
1970, such as needing to perform filesystem checks at every boot.
On top of this, use of NTP is still recommended to deal with the fake
clock "drifting" while the hardware is halted or rebooting.
$ apt-cache showpkg fake-hwclock
0.9 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_jessie_main_binary-armhf_Packages) (/var/lib/dpkg/status)
0.9 - init-system-helpers (2 1.18~) cron (16 (null)) cron-daemon (0 (null)) ntp (0 (null))
$ dpkg -l | grep fake-hw
ii fake-hwclock 0.9 all Save/restore system clock on machines without working RTC hardware
$ man fake-hwclock
FAKE-HWCLOCK(8) System Manager's Manual FAKE-HWCLOCK(8)
fake-hwclock - Control fake hardware clock
fake-hwclock [ command ] [ force ]
Many embedded Linux systems do not have a functional hardware clock.
Either they simply don't have a hardware clock at all or they have a
hardware clock but it is not usable (e.g. because Linux doesn't know
how to use it or because no battery is present).
This can lead to time moving backwards to some default value (often
1970) when the system is rebooted. Since lots of software assumes that
time only moves forward this is a bad thing. NTP can (and should where
practical) be used to sync with an external timeserver but it is not
available early in the boot process and may be unavailable for other
The design expectation of fake-hwclock is that it will be run very late
at shutdown and very early at boot. This will ensure that fsck has a
vaguely sensible idea of system time at boot and won't complain that
the last-modified time in the filesystem is not hugely in the past or
future. Some users may not worry about this too use case, in which case
it is possible to modify the init system configuration to move things
earlier/later as appropriate.
fake-hwclock sets and queries a fake "hardware clock" which stores the
time in a file. This program may be run by the system administrator
directly but is typically run by init (to load the time on startup and
save it on shutdown) and cron (to save the time hourly).
If no command is given then fake-hwclock acts as if the save command
save Save the time to the file. If force is specified fake-hwclock
will move the saved clock either backwards or forwards. Other‐
wise it will only move it forwards.
load Load the time from the file. If force is specified fake-hwclock
will move the clock either backwards or forwards. Otherwise it
will only move it forwards.
The file used to store the time
The init script used to run fake-hwclock on startup and shutdown
systemd service used to run fake-hwclock on startup and shutdown
Settings file for the init script.
Cron job used to save the time hourly
FILE set the file used by fake-hwclock
1 is returned for invalid commands. 0 is returned in all other cases.
This approach can only provide a crude approximation of what a real
hardware clock provides. Use of NTP or another method to keep the time
in sync is strongly advised.
Debian 1 October 2014 FAKE-HWCLOCK(8)
$ man update-rc.d
UPDATE-RC.D(8) sysv-rc UPDATE-RC.D(8)
update-rc.d - install and remove System-V style init script links
update-rc.d [-n] [-f] name remove
update-rc.d [-n] name defaults
update-rc.d [-n] name disable|enable [ S|2|3|4|5 ]
update-rc.d updates the System V style init script links /etc/rcrun‐
level.d/NNname whose target is the script /etc/init.d/name. These
links are run by init when it changes runlevels; they are generally
used to start and stop system services such as daemons. runlevel is
one of the runlevels supported by init, namely, 0123456789S, and NN is
the two-digit sequence number that determines where in the sequence
init will run the scripts.
This manpage documents only the usage and behaviour of update-rc.d.
For a discussion of the System V style init script arrangements please
see init(8) and the Debian Policy Manual.
INSTALLING INIT SCRIPT LINKS
update-rc.d requires dependency and runlevel information to be provided
in the init.d script LSB comment header of all init.d scripts. See the
insserv(8) manual page for details about the LSB header format.
When run with the defaults option, update-rc.d makes links named
/etc/rcrunlevel.d/[SK]NNname that point to the script /etc/init.d/name,
using runlevel and dependency information from the init.d script LSB
If any files named /etc/rcrunlevel.d/[SK]??name already exist then
update-rc.d does nothing. The program was written this way so that it
will never change an existing configuration, which may have been cus‐
tomized by the system administrator. The program will only install
links if none are present, i.e., if it appears that the service has
never been installed before.
Older versions of update-rc.d also supported start and stop options.
These options are no longer supported, and are now equivalent to the
A common system administration error is to delete the links with the
thought that this will "disable" the service, i.e., that this will pre‐
vent the service from being started. However, if all links have been
deleted then the next time the package is upgraded, the package's
postinst script will run update-rc.d again and this will reinstall
links at their factory default locations. The correct way to disable
services is to configure the service as stopped in all runlevels in
which it is started by default. In the System V init system this means
renaming the service's symbolic links from S to K.
The script /etc/init.d/name must exist before update-rc.d is run to
create the links.
When invoked with the remove option, update-rc.d removes any links in
the /etc/rcrunlevel.d directories to the script /etc/init.d/name. The
script must have been deleted already. If the script is still present
then update-rc.d aborts with an error message.
update-rc.d is usually called from a package's post-removal script when
that script is given the purge argument. Any files in the /etc/rcrun‐
level.d directories that are not symbolic links to the script
/etc/init.d/name will be left untouched.
DISABLING INIT SCRIPT START LINKS
When run with the disable [ S|2|3|4|5 ] options, update-rc.d modifies
existing runlevel links for the script /etc/init.d/name by renaming
start links to stop links with a sequence number equal to the differ‐
ence of 100 minus the original sequence number.
When run with the enable [ S|2|3|4|5 ] options, update-rc.d modifies
existing runlevel links for the script /etc/init.d/name by renaming
stop links to start links with a sequence number equal to the positive
difference of current sequence number minus 100, thus returning to the
original sequence number that the script had been installed with before
Both of these options only operate on start runlevel links of S, 2, 3,
4 or 5. If no start runlevel is specified after the disable or enable
keywords, the script will attempt to modify links in all start run‐
-n Don't do anything, just show what we would do.
-f Force removal of symlinks even if /etc/init.d/name still exists.
Insert links using the defaults:
update-rc.d foobar defaults
The equivalent dependency header would have start and stop
dependencies on $remote_fs and $syslog, and start in
runlevels 2-5 and stop in runlevels 0, 1 and 6.
Remove all links for a script (assuming foobar has been deleted
update-rc.d foobar remove
Example of disabling a service:
update-rc.d foobar disable
Example of a command for installing a system initialization-and-shut‐
update-rc.d foobar defaults
Example of a command for disabling a system initialization-and-shutdown
update-rc.d foobar disable
The directory containing the actual init scripts.
The directories containing the links used by init and managed by
Model for use by writers of init.d scripts.
Debian Policy Manual,
insserv(8), sysv-rc-conf(8), bum(8), init(8).
Debian Project 14 November 2005 UPDATE-RC.D(8)
$ apt-cache show ntpdate
Maintainer: Debian NTP Team <firstname.lastname@example.org>
Pre-Depends: dpkg (>= 18.104.22.168)
Depends: netbase, libc6 (>= 2.17), libssl1.0.0 (>= 1.0.1d)
Breaks: dhcp3-client (<< 4.1.0-1)
Description: client for setting system time from NTP servers
NTP, the Network Time Protocol, is used to keep computer clocks
accurate by synchronizing them over the Internet or a local network,
or by following an accurate hardware receiver that interprets GPS,
DCF-77, NIST or similar time signals.
ntpdate is a simple NTP client that sets a system's clock to match
the time obtained by communicating with one or more NTP servers. It
is not sufficient, however, for maintaining an accurate clock in the
long run. ntpdate by itself is useful for occasionally setting the
time on machines that do not have full-time network access, such as
If the full NTP daemon from the package "ntp" is installed, then
ntpdate is not necessary.
$ apt-cache showpkg ntpdate
1:4.2.6.p5+dfsg-7+deb8u2 - netbase (0 (null)) libc6 (2 2.17) libssl1.0.0 (2 1.0.1d) dpkg (2 22.214.171.124) lockfile-progs (0 (null)) dhcp3-client (3 4.1.0-1)
$ dpkg -l | grep ntpdate
ii ntpdate 1:4.2.6.p5+dfsg-7+deb8u2 armhf client for setting system time from NTP servers
$ man ntpdate
ntpdate(8) System Manager's Manual ntpdate(8)
ntpdate - set the date and time via NTP
ntpdate [-bBdoqsuv] [-a key] [-e authdelay] [-k keyfile] [-o version]
[-p samples] [-t timeout] server [...]
ntpdate sets the local date and time by polling the Network Time Proto‐
col (NTP) server(s) given as the server arguments to determine the cor‐
rect time. It must be run as root on the local host (unless the option
-q is used). A number of samples are obtained from each of the servers
specified and a subset of the NTP clock filter and selection algorithms
are applied to select the best of these. Note that the accuracy and
reliability of ntpdate depends on the number of servers, the number of
polls each time it is run and the interval between runs.
ntpdate can be run manually as necessary to set the host clock, or it
can be run from the host startup script to set the clock at boot time.
This is useful in some cases to set the clock initially before starting
the NTP daemon ntpd. It is also possible to run ntpdate from a cron
script. However, it is important to note that ntpdate with contrived
cron scripts is no substitute for the NTP daemon, which uses sophisti‐
cated algorithms to maximize accuracy and reliability while minimizing
resource use. Finally, since ntpdate does not discipline the host clock
frequency as does ntpd, the accuracy using ntpdate is limited.
Time adjustments are made by ntpdate in one of two ways. If ntpdate
determines the clock is in error more than 0.5 second it will simply
step the time by calling the system settimeofday() routine. If the
error is less than 0.5 seconds, it will slew the time by calling the
system adjtime() routine. The latter technique is less disruptive and
more accurate when the error is small, and works quite well when ntp‐
date is run by cron every hour or two.
ntpdate will decline to set the date if an NTP server daemon (e.g.,
ntpd) is running on the same host. When running ntpdate on a regular
basis from cron as an alternative to running a daemon, doing so once
every hour or two will result in precise enough timekeeping to avoid
stepping the clock.
-a key Enable the authentication function and specify the key identi‐
fier to be used for authentication as the argument keyntpdate.
The keys and key identifiers must match in both the client and
server key files. The default is to disable the authentication
-B Force the time to always be slewed using the adjtime() system
call, even if the measured offset is greater than +-128 ms. The
default is to step the time using settimeofday() if the offset
is greater than +-128 ms. Note that, if the offset is much
greater than +-128 ms in this case, that it can take a long time
(hours) to slew the clock to the correct value. During this
time, the host should not be used to synchronize clients.
-b Force the time to be stepped using the settimeofday() system
call, rather than slewed (default) using the adjtime() system
call. This option should be used when called from a startup file
at boot time.
-d Enable the debugging mode, in which ntpdate will go through all
the steps, but not adjust the local clock. Information useful
for general debugging will also be printed.
Specify the processing delay to perform an authentication func‐
tion as the value authdelay, in seconds and fraction (see ntpd
for details). This number is usually small enough to be negligi‐
ble for most purposes, though specifying a value may improve
timekeeping on very slow CPU's.
Specify the path for the authentication key file as the string
keyfile. The default is /etc/ntp.keys. This file should be in
the format described in ntpd.
Specify the NTP version for outgoing packets as the integer ver‐
sion, which can be 1 or 2. The default is 3. This allows ntpdate
to be used with older NTP versions.
Specify the number of samples to be acquired from each server as
the integer samples, with values from 1 to 8 inclusive. The
default is 4.
-q Query only - don't set the clock.
-s Divert logging output from the standard output (default) to the
system syslog facility. This is designed primarily for conve‐
nience of cron scripts.
Specify the maximum time waiting for a server response as the
value timeout, in seconds and fraction. The value is is rounded
to a multiple of 0.2 seconds. The default is 1 second, a value
suitable for polling across a LAN.
-u Direct ntpdate to use an unprivileged port for outgoing packets.
This is most useful when behind a firewall that blocks incoming
traffic to privileged ports, and you want to synchronise with
hosts beyond the firewall. Note that the -d option always uses
-v Be verbose. This option will cause ntpdate's version identifica‐
tion string to be logged.
ntpdate's exit status is zero if it found a server and could update the
clock, and nonzero otherwise.
- encryption keys used by ntpdate.
The slew adjustment is actually 50% larger than the measured offset,
since this (it is argued) will tend to keep a badly drifting clock more
accurate. This is probably not a good idea and may cause a troubling
hunt for some values of the kernel variables tick and tickadj.
David L. Mills (email@example.com)
This manpage converted from html to roff by Fabrizio Polacco <fpo‐
$ sudo nano /etc/rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
# set system-clock script
1 Jan 09:00:07 ntpdate: ntpdate firstname.lastname@example.org Mon Jul 25 22:35:35 UTC 2016 (1)
Error resolving ntp.nict.jp: Name or service not known (-2)
1 Jan 09:00:07 ntpdate: Can't find host ntp.nict.jp: Name or service not known (-2)
1 Jan 09:00:07 ntpdate: no servers can be used, exiting