V2Ray —— VPS KVM time always drifts (导致到V2Ray Server功能失效)
[i=s] 本帖最後由 角色 於 2019-3-6 09:08 編輯 [/i]因为VPS里的KVM时间是经常改变,有的时候你觉得不知道为什么,你的VPS就不能工作,你第一时间要看你的VPS是否对!因为client and server nodes的时间差不能大于90秒。[code]
date
[/code],
你要比较我们常用的北京时间:
[url]https://www.timeanddate.com/time/zone/china/beijing[/url]
[url]https://time.is/zh/Beijing[/url]
如果不对就要把system time调好[code]
date --set="20170413 21:14"
[/code], 上面是2017年4月12日21点14分。
因为这个时间会非常漂移,有的时候会超过90秒。
不过VPS里的hwclock就不会漂移那么多,还有非常准确。所以我们可以把system time写入hardware clock(RTC)[code]
hwclock --systohc
[/code].
从hardware clock (RTC)里的信息调入system clock[code]
hwclock --hctosys
[/code].
我们也可以直接set hardware clock (RTC)[code]
hwclock --set --date="2019-02-22 16:23:30"
[/code].
References:
[1] [url]https://www.linode.com/docs/tools-reference/tools/use-the-date-command-in-linux/[/url]
[2] [url]https://www.thegeekstuff.com/2013/08/hwclock-examples/?utm_source=tuicool[/url]
[3] [url]https://www.cyberciti.biz/faq/rhel-fedora-centos-configure-ntp-client-server/[/url] [i=s] 本帖最後由 角色 於 2019-3-7 00:36 編輯 [/i]
上面帖子已经说过,VPS的machine time经常会drift,而VPS又不能使用ntp,所以我们可以每天都把hwclock copied to system time。
1、Change directory to /etc/cron.daily
2、sudo vi update-time with the following script[code]
#!/bin/sh
/usr/sbin/hwclock --hctosys
exit 0
[/code].
3、chmod +x /etc/cron.daily/update-time
Cron job references:
[1] [url]https://opensource.com/article/17/11/how-use-cron-linux[/url]
頁:
[1]