gpt4 book ai didi

linux - 如何通过 Bash 在 Linux 中设置重启后不变的时间?

转载 作者:太空宇宙 更新时间:2023-11-04 10:01:49 24 4
gpt4 key购买 nike

我正在尝试编写一个手动设置时间和日期的 bash 脚本,这项工作有效,但在重新启动我的系统 (Ubuntu 18.04) 后,时间和日期重置为自动模式。我如何为重启后不变的设置时间/日期编写 bash?

我作为初学者的尝试以这个 Bash 脚本结束:

#!/bin/bash
# A simple bash script to set system date & time
timedatectl set-ntp 0
date +%Y%m%d -s $1
date +%T -s $2":00"

最佳答案

timedatectl set-ntp 0 && timedatectl set-time 'HH:MM:SS' 将关闭网络时钟同步并让您手动更新它。

关于linux - 如何通过 Bash 在 Linux 中设置重启后不变的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55594090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com