What happens when a script scheduled by 'Install on Timer Script' was scheduled to run and the computer is sleeping
Don't know. Perhaps you could experiment and find out?
What happens if FM is exited while a script is scheduled?
Each "timer" is set to a specific FileMaker window. When that window closes, the timer is canceled out. Inistall OnTimer with no parameters will also cancel the timer in the current window.
Experimenting would be a whole lot easier if there were somewhere to see the timer schedule for what's in queue. Just when I think I understand how it works, it throws me a curve.
As a test, I'd set the timer script to create a new record in a table, then define a timestamp field that auto-enters the creation timestamp. Then fire off the script that installs the timer, walk away and let the inactivity allow your machine to sleep, return and wak it up, wait longer than the interval specified by InstallOnTimerScript and then examine the records in a table view to see how many records were created and whether any were created after hibernation and after being awakened. I suspect that none will be created while the computer is sleeping.
Well, near as I can tell, when you install a timer script, the system does a countdown to execution.
So if you specify 600 seconds (10 minutes) and the computer goes to sleep at minute 1 and wakes up at minute 6, the script won't run until minute 15, not minute 10. The computer needs to be 'active' for 600 seconds.
Likewise, if the computer went to sleep at minute 8 and woke up at minute 12, the script would run at minute 14, not as soon as the computer wakes up.
For my application, the scripts are delayed 8, 12, or 24 hours before running again, but there is an urgency to run them as soon as possible. Since this occurs infrequently, and is not an everyday event, it is not unlikely that the user will inadvertently close the lid on their laptop overnight, or forget to turn off the energy saver on their computer for this cycle. This will delay the desired executions of the script. When the user pops the computer open in the morning they may have lost 6,8, or more hours of 'countdown'. The timer needs to be reset when the computer has been asleep to compensate for the time the computer was asleep.
So my problem is how to detect that the computer was asleep and for how long - without introducing significant overhead. I'm working on that now. Any suggestions?
IF this is a hosted file, take a look at whether or not you can use a server schedule for this so that this takes place on the server, not a client machine. That, in turn, will completely avoid the issue.
Only other thing I can think of is a Timer with a much shorter interval--say every 5 minutes or so that checks a timestamp field or global variable to compare to the current timestamp to see when enough time has elapsed that the timer controlled script should be performed.
It's not hosted.
I like the last suggestion. Thanks!