Best way to check if a script is ran today?
Posted: 27 Oct 2022, 02:39
I want a script to run only once per day. Right now I'm checking it by saving today's date into a text file. But I wonder if there's any low-level way, like is there a record in the system logging the last accessed date of a file or something like that?
![Thinking :think:](./images/smilies/icon_think.gif)
Code: Select all
WasIRan() {
static save_filepath := A_ScriptDir "\" A_ScriptName ".last_run"
FileRead last_run, % save_filepath
FormatTime this_run, , yyyyMMdd
if (last_run != this_run) {
FileDelete % save_filepath
FileAppend % this_run, % save_filepath
return true
}
}