Created
May 1, 2022 14:20
-
-
Save eNV25/393cc77734484871cae1a2ca6395f970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/timesync.service | |
[Unit] | |
Description=time sync using HTTP Date header | |
Wants=network-online.target network.target | |
After=network-online.target network.target | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/bash -c '{ exec {sleep}<> <(:); while ! : >/dev/tcp/time.google.com/80; do read -r -t 1 -u $$sleep; done; } 2>/dev/null; true' | |
ExecStart=/bin/bash -c 'timedatectl set-time "$(date +"%%Y-%%m-%%d %%H:%%M:%%S %%Z" -d"$(curl -sSI http://time.google.com | grep -i "Date: " | cut -d" " -f2-)")"' | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment