VPS上日期不对,不便于日志分析,于是修改时区
CentOS 7引入了一个timedatectl命令
用法:
root@localhost:/home/frost# timedatectl --help timedatectl [OPTIONS...] COMMAND ... Query or change system time and date settings. -h --help Show this help message --version Show package version --no-pager Do not pipe output into a pager --no-ask-password Do not prompt for password -H --host=[USER@]HOST Operate on remote host -M --machine=CONTAINER Operate on local container --adjust-system-clock Adjust system clock when changing local RTC mode Commands: status 显示当前时间设置 set-time 设置时间 set-timezone 设置时区 list-timezones 列出已有时区 set-local-rtc BOOL Control whether RTC is in local time set-ntp BOOL Control whether NTP is enabled
所以,执行命令
timedatectl set-timezone Asia/Shanghai修改时区为上海
Linux通用化时区设置
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime