>公司前段时间换服务器,旧的那个拿来搭ubuntu了,可以代替我跟交换机、防火墙之类的设备打交道,毕竟其他几台服务器都是windows。。。真的没有兴趣研究。
>在我接手之前,公司和总部之间的IPSEC总是30小时左右就掉一次,后来发现掉了重启了就完事了,于是写了一个python脚本,跟防火墙打交道,重启IPSEC协议。
>然后用crontab定时每天早上六点执行这个脚本,结果发现第二天还是掉了,我看了一眼日志,没有东西,怎么会呢,就是因为系统时间还没到。
>进入正题
查看当前系统时间:
#:sudo hwclock -r
2020-08-17 15:16:30.217958+0800
执行以下命令,按提示根据自身情况选择时区:亚洲-中国-北京 <键入序号即可>
#:sudo tzselect
命令结果结尾为:
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
设置软连接
#:sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
查看当前系统时间:
#:sudo hwclock -r