Search code examples
cunixdirectoryutilityif-modified-since

Is there a way to check the last time a program was run? (C in Unix)


I'm writing a program/utility in C to find (and then move to a new directory) the files in the current directory that have been modified after the last time the utility was run.

What I'm trying to find out is if there is a way to find the last time this utility ran. Or alternatively, a way to store the time in the program (so as to compare the last stored time against the current time, and then update the "last time" variable to current time).

As I type this it occurs to me that I could write the time to a file (overwriting the single entry as the utility is run) and retrieve the value from the file in the program, although I don't know if this would be the best approach.


Solution

  • you can make a class contains info and serialize it to a text file , it's more easy to access and can store multiple values, then to store new values first delete file and then create file again.

    another approach could be a register key containing information.

    hope it would be useful ;)