1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

Userland: Add an "adjtime" utility

It's a thin userland wrapper around adjtime(2). It can be used
to view current pending time adjustments, and root can use it to
smoothly adjust the system time.

As far as I can tell, other systems don't have a userland utility
for this, but it seems useful. Useful enough that I'm adding it to
the lagom build so I can use it on my linux box too :)
This commit is contained in:
Nico Weber 2020-11-05 15:58:29 -05:00 committed by Andreas Kling
parent 323e727a4c
commit 5fcd34b810
3 changed files with 116 additions and 0 deletions

View file

@ -0,0 +1,36 @@
## Name
adjtime - print remaining system clock adjustment, and optionally set it
## Synopsis
```sh
adjtime [options...]
```
## Description
`adjtime -s delta_seconds` will smoothly adjust the system time by slowing it
down (if `delta_seconds` is negative) or speeding it up (if `delta_seconds` is
positive) by a fraction of a second. The larger `delta_seconds` is, the longer
this takes. If `delta_seconds` is set and a previous time adjustment is in
progress, the remaining adjustment is canceled. That is, if `adjtime -s 1` is
called, and then `adjtime -s 1` is called again later when only 0.3s of the
first `adjtime` call have been applied yet, the clock is adjusted by 1.3
seconds total, not by 2 seconds.
`adjtime` also prints the remaining system clock adjustment.
## Options
* `-s delta_seconds`, `--set delta_seconds`: Adjust system time by
`delta_seconds`. Must be superuser.
## Examples
```sh
# adjtime -s 4.2
4.2
# sleep 1 && adjtime
4.1
```