[英]How to know the file is modifed in linux
I want to know what system call is used in linux C programming is used to know whether a file is modified.我想知道linux用什么系统调用 C编程是用来知道一个文件是否被修改的。 I know that make utility compiles the file using the modification dates only.
我知道 make 实用程序仅使用修改日期编译文件。 I want know how to find whether the file is modified or not.
我想知道如何查找文件是否被修改。
Thanks in advance提前致谢
stat(2)
gives you file times and more.stat(2)
为您提供文件时间等等。
You can look into fcntl(2)
and F_NOTIFY
flag - you'd have to open the directory, not the file itself though.您可以查看
fcntl(2)
和F_NOTIFY
标志 - 您必须打开目录,而不是文件本身。 Or the newer Linuxinotify(7)
facility.或者更新的 Linux
inotify(7)
工具。
You can use ls
and various flags on it, like -l or -t and pipe to grep
or something.您可以在其上使用
ls
和各种标志,例如 -l 或 -t 和 pipe 到grep
或其他东西。 That will tell you when the last file was modified.这将告诉您最后一个文件何时被修改。 But it doesn't really tell you if the file was modified.
但它并没有真正告诉你文件是否被修改。 I think the only real way you can know that is if you are keeping track of when the last time it was modified in general (like checking from backups or something).
我认为你能知道的唯一真正的方法是你是否在跟踪上次修改它的时间(比如检查备份或其他东西)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.