# batch processor/scheduler configuration/setup help?

**URL:** <https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151>\
**Category:** Classic Servoy\
**Created:** [February 26, 2007, 9:22pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151 "2007-02-26T21:22:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [February 26, 2007, 9:22pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/1 "2007-02-26T21:22:45Z")

</div>

Hi everyone,

I’m still having some trouble setting up a batch processor. headless client. I’m hoping someone can point me in the right direction.

I need to run a script that sends out automated emails every 1/2 hour(depending on the search criteria). My script looks something like this:

plugins.scheduler.addCronJob(‘30mins’,‘0 0/2 \* \* \* ?’, globals.emails\_all)

i then went to the web-admin and added my solution. (I didn’t enter anything in arguments since i’m not sure what to enter).

The main problem is that when it’s running, all the clients get the “script” effect too. If the script finds no records, then all of sudden, the client that’s log into solution all of a sudden shows 0 records. Am i doing something wrong? Can someone enlighten me on this?

thanks,  
sammy

Using Servoy version 3.1.3-build 407, repository version 29  
java.vm.version=1.5.0\_06-b05

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 26, 2007, 9:41pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/2 "2007-02-26T21:41:37Z")

</div>

Hi Sammy,

Your clients see the effect because the method is also scheduled in their client.

What you need to do is to let the scheduling method know it is called from the batchprocessor.  
The argument property is exactly what you need for this.  
Your scheduling method will look something like this:

```auto
var bIsBatchProcessor = arguments[0];

if ( bIsBatchProcessor )
{
  plugins.scheduler.addCronJob('30mins','0 0/2 * * * ?', globals.emails_all);
}

```

Now launch the solution as a batchprocessor and give it the parameter ‘true’ (no quotes).  
That’s all.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![automazione](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@automazione](https://forum.servoy.com/u/automazione)\
**Post date:** [February 26, 2007, 10:05pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/3 "2007-02-26T22:05:03Z")

</div>

Maybe can be a good idea to create a micro-application whose only objective is to schedule your mail process. Set this application as “module” so it is not shown with the normal application selection and start it in the servoy-admin as a batch process. Works fine for me. Of course you can also use this application to schedule or invoke other batch tasks.

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 26, 2007, 11:02pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/4 "2007-02-26T23:02:51Z")

</div>

Enrico’s suggestion is the best approach when you can.

I have created a batch processor module as well.  
Issue was that I needed much of the functionality of the ‘main’ solution though.  
It was a no-brainer that I was not going to redo the job so I decided to use that ‘main’ solution as a module.  
Works like a charm and it give me more control and less ‘spaghetti’ coding than integrating both in one solution.

---

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [March 30, 2007, 1:19am UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/5 "2007-03-30T01:19:06Z")

</div>

> ROCLASI:  
> Hi Sammy,
> 
> Your clients see the effect because the method is also scheduled in their client.
> 
> What you need to do is to let the scheduling method know it is called from the batchprocessor.  
> The argument property is exactly what you need for this.  
> Your scheduling method will look something like this:
> 
> ```auto
> var bIsBatchProcessor = arguments[0];
> 
> ```

if ( bIsBatchProcessor )  
{  
plugins.scheduler.addCronJob(‘30mins’,‘0 0/2 \* \* \* ?’, globals.emails\_all);  
}

> ```auto
> 
> Now launch the solution as a batchprocessor and give it the parameter 'true' (no quotes).
> That's all.
> 
> Hope this helps.
> 
> ```

I just got a chance to work on this again. All my script has to do is send out an email when a new record is created in Servoy. I tried running this on developer. I followed exactly what you said putting launch batchprocessor parameter as true (no quotes). However, after I create a new record, no email gets sent. My email server is runing because if i run the email new record script manually, it works just fine. I reduced the interval to 2 minutes…still nothing. Anything else i’m doing wrong?

here’s my search script\>

forms.admin\_capa.controller.find()  
forms.admin\_capa.a\_capa\_opened\_notified = ‘no’  
var found = forms.admin\_capa.controller.search()

for (var n = 1; n \<= found; n++ )  
{  
forms.admin\_capa.controller.recordIndex = n;  
var to = ‘szheng1@ndcus.jnj.com’ //change to Maritza later , keyword bauer  
var from = ‘ndc\_fmodbc1@ndcus.jnj.com’  
var subject = ‘A new CAPA , CAPA # ’ + forms.admin\_capa.main\_capa\_num + ’ has just been opened’  
var msgText =‘A new CAPA, CAPA # ’ + forms.admin\_capa.main\_capa\_num + ’ has just been opened. Please log into Servoy CAPA system to find out more details.’  
plugins.mail.sendMail( to, from, subject, msgText)  
forms.admin\_capa.a\_capa\_opened\_notified = ‘yes’  
application.sleep(1000)

}

here’s my scheduler script\>  
var bIsBatchProcessor = arguments[0];

if ( bIsBatchProcessor )  
{  
plugins.scheduler.addCronJob(‘2mins’,‘0 0/2 \* \* \* ?’, globals.emails\_all);  
}

am i doing something wrong.  
thanks again for your help

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [March 30, 2007, 11:39am UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/6 "2007-03-30T11:39:12Z")

</div>

Hi Sammy,

I guess we can assume the method works so lets concentrate on the scheduler.  
One thing you have to know, you can only add a schedule with the same name once. So if you want to reset it you need to remove it first.  
So the code would look like this.

```auto
var bIsBatchProcessor = arguments[0]; 

if ( bIsBatchProcessor ) 
{ 
  plugins.scheduler.removeJob('30mins');
  plugins.scheduler.addCronJob('30mins','0 0/2 * * * ?', globals.emails_all); 
}

```

Now load the batchprocessor and keep an eye on the server log for errors and ‘User idle since’ times under the Client page . It should show activity every 2 minutes.  
If it doesn’t then you know it isn’t running.  
Also putting application.output() functions in the code might help tracking what’s going on. This out shows up in the serverlog.  
Like so:

```auto
var bIsBatchProcessor = arguments[0]; 

if ( bIsBatchProcessor ) 
{ 
  application.output('Scheduling 30mins method');
  plugins.scheduler.removeJob('30mins');
  plugins.scheduler.addCronJob('30mins','0 0/2 * * * ?', globals.emails_all); 
}

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [March 30, 2007, 4:30pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/7 "2007-03-30T16:30:24Z")

</div>

Robert,

thanks for your continual help in this problem. The updated code you gave me still didn’t work. The headless client remains idle. I also don’t see anything in the server log. (thru the web-admin) Am I looking in the right place?

However, i went back to my original code which is just one single line

plugins.scheduler.addCronJob(‘30mins’,‘0 0/2 \* \* \* ?’, globals.emails\_all)

And the emails are working fine. However, this brings me to the original problem of all the clients are see the “script” effect too.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [March 30, 2007, 5:54pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/8 "2007-03-30T17:54:35Z")

</div>

This is so odd.  
Well you could make it so it only runs in a headless client (which what the batchprocessor is) with the following code.

```auto
if ( application.getApplicationType() == 4 ) // Headless Client
{ 
  application.output('Scheduling 30mins method'); 
  plugins.scheduler.removeJob('30mins'); 
  plugins.scheduler.addCronJob('30mins','0 0/2 * * * ?', globals.emails_all); 
}

```

Of course when you want to use a headless client for webbased stuff then you have the same issues as with the rich client again.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [March 30, 2007, 7:00pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/9 "2007-03-30T19:00:45Z")

</div>

> ROCLASI:  
> This is so odd.  
> Well you could make it so it only runs in a headless client (which what the batchprocessor is) with the following code.
> 
> ```auto
> if ( application.getApplicationType() == 4 ) // Headless Client
> 
> ```

{  
application.output(‘Scheduling 30mins method’);  
plugins.scheduler.removeJob(‘30mins’);  
plugins.scheduler.addCronJob(‘30mins’,‘0 0/2 \* \* \* ?’, globals.emails\_all);  
}

> ```auto
> 
> Of course when you want to use a headless client for webbased stuff then you have the same issues as with the rich client again.
> 
> Hope this helps.
> 
> ```

it’s working perfectly now. Thanks again for your help Robert!!!

---

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.servoy.com/u/pmo)\
**Post date:** [February 12, 2010, 12:32am UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/10 "2010-02-12T00:32:18Z")

</div>

I’m new at the batch thing.  
I’m trying to test a scheduled job to run every minute.  
i made a separate module for the batch process.  
Here’s my call to add the cron job:

plugins.scheduler.addCronJob(‘Sample\_Followup’,‘0 0/60 \* \* \* ?’,gm\_sample\_followup);

It is not currently working.  
I also tried this:  
plugins.scheduler.addCronJob(‘Sample\_Followup’,‘\* \* \* \* \* ?’,gm\_sample\_followup);

But then i get the emails like every second…  
It seems like this timing format is different from the normal operating system crontab format.  
What does the ? mean?  
Is there better documentation on how to format this thing?  
Thanks

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [February 12, 2010, 12:48am UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/11 "2010-02-12T00:48:08Z")

</div>

Jason Meunier did a webinar today about it, I suppose it has been recorded, so check it out:  
[http://forum.servoy.com/viewtopic.php?f=26&t=13666](http://forum.servoy.com/viewtopic.php?f=26&t=13666)

He posted a link to the Quartz cron syntax (Quartz is the Java Open Source library that Servoy is using in its scheduler plugin).  
Check: [http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html](http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html)

---

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.servoy.com/u/pmo)\
**Post date:** [February 12, 2010, 8:38pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/12 "2010-02-12T20:38:28Z")

</div>

Thank you so very much!  
This Quatz link was exactly what I was looking for.  
For some reason in Servoy Developer, the sample code points to an invalid web URL.  
That’s why I didn’t have this info.  
Thank again.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 16, 2010, 1:18pm UTC](https://forum.servoy.com/t/batch-processor-scheduler-configuration-setup-help/7151/13 "2010-02-16T13:18:05Z")

</div>

i updated the url in the scheduler sample code.
