暂停 Linux 日期时间
我正在开发一个产品,其中业务逻辑根据日期而变化,为了帮助 UAT 测试,如果我们能够冻结 Linux 服务器上的日期/时间,那就太好了。
是否可以暂停服务器上的日期/时间滚动到第二天?
也许唯一的方法是创建一个每天运行的脚本来调整日期/时间,任何想法都值得赞赏。
谢谢
I'm working on a product where the business logic changes based on the date and in order to help UAT testing it would be great if we could freeze the date/time on our Linux server.
Is it possible to suspend the date/time on the server from rolling over to the next day ?
Maybe the only way is to create a script which runs daily to adjust the date/time, any thoughts appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 LD_PRELOAD 并重定向检索时间的库函数 - 可以在此处找到示例< /a>
Use LD_PRELOAD and redirect the library functions that retrieve time - An example can be found e.g. here
我认为你最好的选择是,正如你所建议的,设置一个脚本来重置时间。可能有更奇特的方法可以做到这一点,但最终结果是相同的。请注意,“冻结”时间会产生副作用。依赖文件修改日期的构建系统以及假设时钟始终向前移动的守护进程可能会感到困惑。
I think your best bet is, as you suggest, setting up a script to reset the time. There may be more exotic ways to do this but in the end the result is the same. Just be aware that there will be side-effects to "freezing" the time. Build systems that rely on file modification dates may be confused, as well as daemon processes that assume the clock is always moving forward.