设置永久系统日期

Dar*_*añé 2 linux date

我需要在 Linux 测试服务器中为时间敏感的软件设置一个永久的系统日期,这些软件需要这个时间循环(土拨鼠日的风格)或弯曲时间(Hiro 的风格),你说出来的。

我在每天 00:00 使用 cron 尝试调用 date 来设置所需的日期。没有成功。

附带说明一下,在 Ruby 中可以在代码中使用,但我需要在系统范围内使用它。

Kyl*_*ndt 7

使用 date 命令对我来说很有意义,您的 cron 日志中是否有任何错误?cron 作业是否以超级用户身份运行(需要更改系统时间)。也许发布 cron 作业以便我们可以对其进行故障排除?

此外,请确保 ntpd 未运行并在更改时钟后重置时钟:

/etc/init.d/ntpd status
Run Code Online (Sandbox Code Playgroud)

另外,请确保 ntpd 不会在启动时启动:

对于 Redhat/Centos 系列:

sudo chkconfig ntp #Maybe ntpd
Run Code Online (Sandbox Code Playgroud)

如果您看到数字比:

sudo chkconfig ntpd off
Run Code Online (Sandbox Code Playgroud)

对于 Debian:

ls /etc/rc*.d/*ntp* #To check
update-rc.d -f ntp remove #to remove
Run Code Online (Sandbox Code Playgroud)