如何在bash中设置时间,重启后不会改变?

问题描述 投票:0回答:2

我正在尝试编写一个手动设置时间和日期的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"
linux bash shell ubuntu
2个回答
1
投票

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


0
投票

我是用硬件时钟做的。

© www.soinside.com 2019 - 2024. All rights reserved.