Pages

Wednesday, October 6, 2010

Running Scheduled Agents from Server Console

When working with scheduled agents, we often tend to run the agent by right clicking it and clicking on run or calling it on a button click before we schedule it. It may not work always, cos scheduled agents will have a lot of issues that are not associated with a normal agent which may run properly with your security permissions when you run it.

For example you may have a role enabled for you on the ACL where as your server may not.
So Scheduled when they run automatically will run with server rights over the database and hence may result in different results.

So the best way I know to test the working of a scheduled agent is by running it through the following command,

Tell Amgr Run "DatabasePath" 'AgentName'

Mind the usage of the single and the double quotes. They must not be changed.

Hope this helps :)

3 comments:

  1. Some clarifications.

    1. Scheduled agents run with the access rights of the signature they are signed under*, or what rights they have been set to run under in the agent properties.

    2. "Tell amgr run" does not run the agent as a scheduled agent, instead it runs it in it's own thread.

    Scheduled agents can only run 1 per database at a given time. "Tell AMGR Run" does not have that restriction. So some care should be taken when using that method with an already scheduled agent.

    * There are exceptions to every rule.
    1. If you use the Evaluate command in your agent, then the code in that statement needs to be compiled at runtime. However the server will not have the private key to sign with the signature of the agent (unless it is signed by the server), so it will run that compiled code under its credentials.
    2. If Agent on server A runs a webagent on server B then it will run under the credentials of Server A, unless the webagent is set to run as someone else.

    ReplyDelete
  2. Be careful with this. It is convenient but is risky if you try this on a production server. Running an Agent this way places it in a new Thread outside of Agent Manager. So as far as I know there's no way to kill this type of agent short of rebooting the server.

    Also if you have the agents set to have a 45 minute (or whatever) execution runtime in the server document, running an agent this way ignores that. So it will run till it's done....

    Maybe this has changed in recent versions, but that's been my experience in the past.

    ReplyDelete
  3. @sodoherty & LaserDude :
    Thats a great piece of information you have shared here. Thanks for suggesting the same. Surely will keep that in mind....
    Agents are typically mysterious :)

    ReplyDelete