如何在一定时间后删除 .txt 文件?

How to delete a .txt file after a certain time?

我有这个显示信息的 .txt 文件,但我想在大约 5 分钟后自行删除。

考虑到您正在做的事情,使用 memcached 不是更好的选择吗? 您只需将 ips 作为 key=value 对存储在 memcached 中,有效期为 5 分钟。因此,您的数据总是每 5 分钟过期一次。 与 memcached 的交互也比文件处理容易得多。