Have you ever come across this little scenario:
- You have a scheduled agent set to run at 5:00 in the morning
- For some reason you need to change something in this agent (or enable it when updated from a template). You do this just before noon…
- What happens? Suddenly, your agent starts running!!! …. and this most likely was not what you expected!
This happens to agents that are scheduled to run once a day. If you modify them in any way later that day they will behave as if they had not run (which they will also tell you, if you right-click on the agent in Domino Designer and select “View log”) – and they will run shortly after! I have seen this confuse many admins (and developers) over time.
I have seen many interesting ways of trying to cope with this from within the code – unfortunately, none of them have been fool-proof, say if the scheduled agent was to run in the evening, i.e. after it was modified).
I have found a simple solution some time ago – and recently saw someone writing about this in another context – so I thought I would share since it is so simple:
- Set your agent to run “More than once a day”
- Set it to allow to run between e.g. 5:00 and 6:00
- Now set it to run every e.g. 5 hours
- Voilá – if you enable the agent after 6:00 then it will not run until tomorrow