Hello folks, can you help me see what I am missing with the following? I am struggling with the Agent schedule options to get a scheduled Agent that will run on any Domino server, but not from a Notes client . . .
I am working on an application that runs a scheduled Agent each night (at 22:00) to do some ‘batch processing’. The application inherits it’s design from a template and the Agent was set in the template to run on the server that hosted the application (‘ServerA’). This works fine.
Then we needed to create a test instance of the application on a separate test server (‘ServerB’), so I changed the Agent in the template to run on “-Any Server-” so the test instance (on ServerB) and the live instance (on ServerA) could both invoke the scheduled Agent. That works fine to.
But! I then created a Local Replica of the test instance on my laptop so I could work off-line while developing some changes that sent e-mail (didn’t want to work on-line and have erroneous mails sent). I was working late one evening (past 22:00 when the scheduled Agent runs) and the Notes client on my laptop ran the scheduled Agent! I though that run on “-Any Server-” would cause a scheduled Agent to only run on Domino servers, not Notes clients (there is a run on option for “Local”)? This is a pain, as I have had to add code to the Agent to spot if it is running on Local (server = “”).
Am I missing something obvious here? Is run on “-Any Server-” dodgy in R6.5.4?
Any help much appreciated.
James.
Subject: -Any Server- scheduled Agents run in Local replicas.
Hi James,a) You could test for servername and if blank exit
Set agent = session.CurrentAgent
thisserver = agent.ServerName
If thisserver = “” Then… exit because you are local
b) You could also check the disable background agents in the db properties on your local replica
c) You could also uncheck ‘enable background agents’ in your local preferences on your laptop
c) You could test for filepath (assuming your local replica is within a different filepath
Any of these help?
Subject: Checking for Local already - Was questioning “-Any Server-”…
Hello Stan, thanks for the quick reply 
I have already updated the scheduled Agent to exit if it is being run on Local. My question was more about the Agent schedule “Run on” option of “-Any Server-”: I had assumed that this would stop the Agent running from a replica on a Notes client, as it is not a Domino server! But that it not what it does 
Subject: More testing: “-Any Server-” runs on Local if user = Agent signer…
I did a little more testing: If the scheduled Agent is set to run on “-Any Server-”, it will only run on a Lotus Notes client if the user (ID being used on the client) is the same as the ID that signed the Agent.
This is slightly helpful, as at least it reduces the exposure of scheduled Agents incorrectly running on Local Replicas. But it means that developers who sign Agents have to be careful what ID they are using if they have Local Replicas of databases that have scheduled Agents.
Maybe I should just make sure I turn my laptop off before 22:00!
Does anyone know if “-Any Server-” works any more intuitively in later versions i.e. won’t run on Notes clients, irrespective of who signed the Agent/what ID the client is logged in with?
Subject: -Any Server- scheduled Agents run in Local replicas.
I haven’t tested it, but I’m fairly sure the -Any Server- option still means the agent can run locally.In a sense, a local PC is a server for this purpose, since scheduled agents always run as a background task without user interaction, regardless of the environment.
In your specific case, I think you could do better with your agent settings. Try this:
In the template, disable the agent, and select the agent property “choose server when agent is enabled”.
Refresh the design of both the live and test databases (first time round, this will disable the agent in both dbs).
Enable the agent separately in the live and test databases, and choose the appropriate server for each.
Once that is done, you can now refresh the design of either the live or test databases, and the agent will remain enabled with whatever server was last set for that database. This will remain the case until the next time you modify the agent.
If you do modify the agent in the template, the next design refresh will disable the agent in each database. Then you’ll have to re-enable the agent and set the server again… but this shouldn’t be a problem unless you’re modifying the agent frequently.
This way, you don’t have to use the -Any Server- option, and you should have no further problem with the agent running locally.
Subject: RE: -Any Server- scheduled Agents run in Local replicas.
One might deduce this behaviour from the fact that “Local” always shows up first in the Servers list in dialogs…
Subject: RE: -Any Server- scheduled Agents run in Local replicas.
One might indeed deduce that, had one scrolled up one line in the “Run on” list. Ah, it has been a long month thus far!
Thanks for pointing this out now Stan. It confirms that Local is considered a server and makes me realise that there is no out-of-the box way to set a scheduled Agent to run on just ‘real’ servers and not clients.
Ho Hum, if NotesAgent.ServerName <> “” it is then.
Subject: Nice idea!
Thanks Scott, I like your idea wrt. selecting the server when it is enabled in each instance.
I’ll have to consider the benefits of this Vs remembering to re-enable the Agent in all instances whenever we change the Agent code.
Many thanks for the alternative angle 