Suppose i have a directory in /tmp/myDir where files are constantly created, modified and destroyed by a daemon.
I need to periodically (every 45 seconds) monitor last created files. To do that i must determine which files were created after the last check.
What would be the best way to do that from a c daemon?
If possible, the method should avoid opening every file in the directory during each check.
inotifyis pretty nifty… If you can’t use that, I would suggest obtaining thest_mtimefor each file in the directory, and comparing it to(time(0) - 45). If it’s greater, then it’s within your 45 second window. Put your executable on thecrontabif you’re rather not create a continually running daemon.