调试,Unix。使用与系统不同的时间运行程序
我正在 MacOSX 中调试程序, 我需要这个程序认为我们比操作系统给出的时间晚了一年。
我无法更改操作系统的时间,因为我需要在正确的时间同时运行第二个程序。 我可以修改第一个程序的代码,使其每次从操作系统获取时间时都添加一年,但代码太大,无法做到这一点;我不想使用这个解决方案。
我曾经听说 Unix 中有一个命令可以使用伪造/模拟时间来运行程序。 你知道吗?
I am debugging a program in MacOSX,
and I need that this program thinks we are one year later than the one given by the operating system.
I cannot change the time of the operation system, because I need to run a second program concurrently with the correct time.
I could modify the code of the first program to add one year each time it gets the time from the operation system, but the code is too big to do that; I prefer not to use this solution.
I heard once that there is a command in Unix to run a program with a fake/mocked time.
Do you know about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有尝试过,但 libfaketime 声称可以满足您的需求。
引自网站:
假设该库按照宣传的那样工作,您可以使用以下命令欺骗您的程序,使其认为它已提前一年运行:
I haven't tried it, but libfaketime claims to do what you need.
Quoted from the website:
Assuming the lib works as advertised, you can trick your program into thinking it was running a year ahead using: