Archlinux开机自动同步时间脚本

Write a oneshot systemd unit:

/usr/lib/systemd/system/ntp-once.service
[Unit]
Description=Network Time Service (once)
After=network.target nss-lookup.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ntpd -q -g -u ntp:ntp ; /sbin/hwclock -w

[Install]
WantedBy=multi-user.target

and enable it:

# systemctl enable ntp-once