< Back

Document Subject: Scheduled Agent without time limit
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#ScheduledAgentWithoutTimeLimit or http://A555F9/nn.nsf/ByAlias/ScheduledAgentWithoutTimeLimit

Went back to an old customer to work on various new projects. Got collared to work on the Lotus Notes leave system. This system is excellent and I have spent a lot of time getting it very useable for lots of people. There are 2 workhorse agents that warn people about the end of the leave period and also transfer unused leave at the end of the period. These agents run every day as leave periods could run from any day of the year. On the 12th of december and the first of january the agents run for a long time as this is the prederred annual leave period. The agents time out as IT have restricted agents to run for 90 minutes at night. How do I change the agents to run forever without timing out?




I considered a few options to run a scheduled agent for more than the alloted time.

NB the allotted time is specified in the NAB. Go to the Configuration -> Servers -> All Server Documents then open up the server doc.

Click on Server Tasks -> Agent Manager. The timeout settings are there. Typical settings are 30mins for day, 90 mins for night.

  1. Have multiple agents that start every hour and continue where the last one left off.
  2. Haver the shceduled agent start another agent using the runonserver method. Not sure if this would work.
  3. Have the agent check the last few days processing to see if any jobs were left undone.
  4. Just run the agent manually in the client on those problem days. This was what was happening currently.
  5. Other way.

It seemed the other way was the answer.

I had noticed that the terminate event in an agent is called when an agent timesout, or when an agent is interrupted using CTRL break when working at another company.

So how  much of a limit does the terminate event have? The answer is for Notes 6.52 server anyway: there is no limit.

Is the terminate event limited in functionality, ie can you define objects, send email etc? No limits on functionality.

So I just moved the whole agent's code from the initialize event to the terminate event. And it ran fine.

I simulated an agent running for 5 hours using sleep 900 which sleeps for 15 minutes, and then sending an email, and doing this for 20 loops. All code in terminate event, and nothing in initialize and the agent ran to completion.

Job done.

A couple of points:

You cannot seem to debug lotusscript in the terminate event, so test in initialize and then run it in terminate.

It might be worth adding a time out option in the agent, to prevent endless loops messing up the server,

Something like this would stop the agent after 6 hours:

Dim st As Variant
st=Now

Do Until processdoc is nothing or (Now - st)*3600 > 360 'mins

  'process etc

loop

I am just getting so sensible in my old age.

PS If this feature of Notes is removed in newer version please let me know ASAP !