linux修改时区且设置24h格式
- 修改时区基本命令
- centos7修改时区并且自动ntp同步
- ubuntu时间改为24h显示
修改时区基本命令
timedatectl list-timezones #列出所有时区
timedatectl | grep local # 确定硬件时钟是否设置为本地时区
timedatectl set-local-rtc 1 # 将硬件始终设置为本地时区
timedatectl set-local-rtc 0 # 将硬件时钟设置为协调世界时(UTC)
timedatectl set-timezone Asia/Shanghai #设置系统时区为上海
执行最后一条即可:timedatectl set-timezone Asia/Shanghai
centos7修改时区并且自动ntp同步
#修改时区:
timedatectl set-timezone Asia/Shanghai#同步时区:(设置同步服务器为阿里云的同步服务器)
yum -y install ntpdate ntp
/usr/sbin/ntpdate ntp1.aliyun.com
echo "*/5 * * * * root /usr/sbin/ntpdate ntp1.aliyun.com > /dev/null 2>&1" >> /etc/crontab
systemctl restart crond.service
ubuntu时间改为24h显示
vim /etc/default/locale
LC_TIME=en_DK.UTF-8