1
votes

My first question on StackOverflow so bear with me ..

I want to create a scheduled agent, to run say tonight between 23:00 and 01:00, every half an hour. It MUST NOT run befpre then.

Domino seems to have me snookered.

If I set the agent schedule to be more than once a day, every half hour, between the times as above, with target All Documents .. it runs straight away after I save it.

If I disable it, set all this up, then enable it .. it runs straight away after being enabled.

It seems that if you have an agent whcih should run more than once a day, it always runs right away.

Note that I'm aware I can put some LotusScript code in the agent to quit if the time is before say 21:00 so that the first run doesn't do anything. Surely .. I shouldn't need to do that!

But anyway, this doesn't help if the agent is a Formula one. There's no option to quit like that, unless you put in something like

@if(@hour(@now)<21;@return("");"continue);

.. as the first line which is really messy.

So .. the question:

How can I set it up so that I save the agent to run more than once a day, and it only runs after the time I specify ?

Thanks!

EDIT: with a LotusScript agent there are a few options on how to stop the first run. However the real issue was a Formula agent. I didn't write the agent and there isn't time to re-write it in LotusScipt- so it has to be formula. It's also much faster in Formula !

The agent ran on 22,000 documents and changed one simple field. The @if(@hour(@now)<21;@return("");"continue); line would work but it's really clumsy.

3
maybe post a screenshot of the scheduling you're usingZach
I'd be curious to see a formula agent that would take too long to re-write in LotusScript to be worth the time.David Navarre
Fair point, but that's not the question (sorry!). There are many such agents with this client, and to adopt an mantra of "well the way you change the scheduled server without running it immediately is to re-write it in lotusscript then put a line in to exit on the first run" is unworkable.user2808054

3 Answers

1
votes

Scheduled agents only run 'immediately' if their scheduled time to run that day has already passed. Since it was scheduled to run until 1am and hadn't yet run, it would run. If it had been scheduled for 2300-2359, it would not.

3
votes

Agents do tend to do that. Have you tried setting it to "Start running agent on this date" and specifying tomorrow's date? It wouldn't run at 23:00 on that first day, but at least it wouldn't run at 14:27 either.

Otherwise, you already seem to have an answer, and it doesn't seem like such a bad one. I do think LotusScript or Java would be a better choice than formula for this one, though. You don't want it to consider all those documents processed. I think if you really don't want it to run at the wrong time, putting the time check in anyway is a good safety measure, and it's just one line.

Yet another option is to set the agent to run "Never", and create one or more program documents in the server's address book, instructing it to run the agent at whatever specific times you wanted.

2
votes

I believe the rule is that all scheduled agents will run immediately after they are saved.

The trick I've used is to setup two agents. One agent will be your primary agent, essentially the one you've just written. Set it to run manually and name it something like "Primary Agent". You'll rename it later.

The second agent should just call the primary agent. You can use this LotusScript:

Dim s as New NotesSession
Dim db as NotesDatabase
Dim agent as NotesAgent

Set db = s.CurrentDatabase
Set agent = db.GetAgent("(Real Name Of Agent)")
agent.Run

Finally, you can rename your first agent to "(Real Name Of Agent)" and you've avoid having it kicked off automatically.

Alternatively you can add a setting to the server's Notes.ini to prevent this auto-run behavior:

Amgr_SkipPriorDailyScheduledRuns=1