地址是:https://github.com/wolfcw/libfaketime
先安装好 git
、gcc
和 make
,然后运行下面的几个命令:
git cone https://github.com/wolfcw/libfaketime.git
cd libfaketime
make
make install
下面以 date
命令为例,编一个脚本,一看你就明白怎么用了:
#!/usr/bin/bash
export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1
export FAKETIME="@2022-08-06 10:00:00"
date
运行上面的脚本会得到输出:
2022年 08月 06日 星期六 10:00:00 CST