Utility Description

To use the utility you can download its either binaries (x32 and x64 Windows platforms supported) or source code and compile. Binaries and jSche Service is prepared to use on Windows platform but if you are a developer it is easy to use the same java compiled code for any platform that Apache Commons Daemon allows to use. If you find your platform unsupported by provided binaries - download the necessary ACD module and update binaries to use it.

Note the binaries contain later batch files versions which allows avoiding use of the JAVA_HOME variable, the only prerequisite is to have java installed on your system (the latest Java version in the Windows registry is being look up to use).

You can either run the scheduler in command line running jScheSrv.bat or setup as the windows service using install_service.bat. The service is setup to run manually so open "windows services", find jSche service there and run it, setup to run it automatically if you want the service to setup along with system startup.

To uninstall it later use uninstall_service.bat. If you want to move the folder with the scheduler into another location, uninstall it in previous place and install again in another.

If you have setup the service and it is not run currently you can use run_in_console.bat to run it in the command line using the same parameters.

config_manager.bat can be used to update VM parameters used for service if it is necessary. If you run update_config.bat it resets parameters to the default ones. Update this file if necessary to change VM parameters permanently. To apply these parameters, run this batch once and restart the service. Parameters are stored into the registry so there is no need to apply them later again if you have no changes done there.

If you are upgrading the java version on your system it's preferable to stop the jSche service first using the stop.bat and start it again after java upgrade using the update&start.bat. Otherwise if you have upgraded your java when the service was running you can also use the update&restart.bat to restart the service under the upgraded java.

Schedule configuration.

This is the example of a schedule configuration in the cmdLine.jSche.xml:

<jScheConfigs>
  <!-- Time zone used to specify times below -->
<!-- The same setting can be used inside each jScheConfig as well and will be used instead of this one in this case -->
<!-- If it is omitted in both settings the one specified in jSche.properties will be used (by default specifies to use local time zone) -->
<timeZone>PST</timeZone>
  <!-- Weekly configurations to run each business day on specified times -->
<!-- It specifies that the event will be fired each business day twice at 11:59 am PST and 11:59 pm PST -->
<!-- If there are several configurations set for the same event it is better to define event reference to use the only event instance -->
<jScheConfig>
<dayOfWeek>MONDAY</dayOfWeek>
<dayOfWeek>TUESDAY</dayOfWeek>
<dayOfWeek>WEDNESDAY</dayOfWeek>
<dayOfWeek>THURSDAY</dayOfWeek>
<dayOfWeek>FRIDAY</dayOfWeek>
<time>11:59</time>
<time>23:59</time>
<eventRef id="dir"/>
</jScheConfig>
  <!-- Daily configurations to run at specified times -->
<!-- It specifies that the event will be fired each day at 8 am EET and 1 pm EET -->
<!-- Time zone specified here overrides time zone setting for this configuration the setting made for all configuration on the top -->
<jScheConfig>
<timeZone>EET</timeZone>

<dayOfWeek/>

<time>08:00</time>
<time>13:00</time>
<eventRef id="dir"/>
</jScheConfig>
  <!-- If there is the only configuration with such event it is probably better to define it directly in this configuration -->
<jScheConfig>
<timeZone>EET</timeZone>

<dayOfWeek/>

<time>09:36</time>
<time>09:37:30</time>
<processExecutor>
<cmdLine>cmd /c cd</cmdLine>
</processExecutor>
</jScheConfig>
  <!-- For each event references defined in the configurations below event must be defined with corresponding IDs -->
<processExecutor id="dir">
<cmdLine>cmd /c dir</cmdLine>
</processExecutor>
</jScheConfigs>

Each <jScheConfig> section here is event scheduling execution setup. You can define here one or more <time> sections specifies time of the day to execute the event. Any number of <dayOfWeek> sections can be added to specify days of week to run the event. To configure each day execution empty <dayOfWeek/> must be specified. Optionally <timeZone> can be specified to set time zone in which <time> is given. If <timeZone> is omitted from the <jScheConfigs> generic section is used. If it hasn't been setup too "vvat.jsche.core.defaultTimeZone" specified in the jSche.properties is used which is set to use default user time zone by default.

To specify the event to run corresponding event name is used as tag name. By default 2 plugins are shipped with the utility to setup events:

If you want to setup several sections with the same event it is better to define the event reference <eventRef id="event_id"/> instead of the direct event and define this event directly in the <jScheConfigs> section with the corresponding id="event_id" event tag argument. The only event instance will be scheduled for all references in this case.

The configuration directory jScheConfigs can contain any number of configuration files that must end with ".jSche.xml" extension. The directory is automatically scanned for configuration files updates - just update, delete or create new file with this extension and it will be scheduled automatically without of service restart.

If you have no <time> section specified for the configuration - it means that this is a test event specification for the only execution. Just resave the configuration file to run such event once. Here is the javaApp_test.jSche.xml configuration example.

<jScheConfigs>
<!-- To test the request NOW just resave this file -->
<!-- If no time is specified then the event is fired just once immediately -->
<jScheConfig>
<javaAppRunner>
<startClass>TestArguments</startClass>
<argument>First argument</argument>
<argument>Second argument</argument>
<argument>Third argument</argument>
</javaAppRunner>
</jScheConfig>
</jScheConfigs>

To configure event execution which must be fired each specified time setup configuration with <time> only section (<dayOfWeek> section is absent).

<jScheConfigs>

<!-- Configuration with time only specification fires event each specified time (each hour in this example) -->
<jScheConfig>
<time>01:00</time>
<processExecutor>
<cmdLine>cmd /c echo Hello, World!</cmdLine>
</processExecutor>
</jScheConfig>
</jScheConfigs>

If you run the utility as the service logs are stored in the jSche.log which is useful to read controlling the schedule and its execution. If you run it using the jScheSrv.bat logs are listed in the command line.

Here is the log example which shows how messages are clear and user-friendly. Each scheduled event reported in initialization which event will be run with which sequence and when is its first execution in time zone translated to the local time zone.

2014-07-13 01:29:45,630 INFO  [main:JSche:73] Starting the scheduler
2014-07-13 01:29:45,697 INFO  [main:DirWatcher:125] Initializing schedules for: cmdLine.jSche.xml
2014-07-13 01:29:45,698 INFO  [main:DirWatcher:125] Initializing schedules for: cmdLine_test.jSche.xml
2014-07-13 01:29:45,698 INFO  [main:DirWatcher:125] Initializing schedules for: javaApp_test.jSche.xml
2014-07-13 01:29:45,700 INFO  [main:DirWatcher:132] Schedulers initialization performed
2014-07-13 01:29:46,701 INFO  [rescheduler:Schedule:137] cmdLine.jSche.xml: canceling all executors
2014-07-13 01:29:46,763 INFO  [rescheduler:Schedule:64] cmdLine.jSche.xml: setting up executors
2014-07-13 01:29:46,776 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [MONDAY, 11:59]{PST} starting at [2014-07-14 21:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,776 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [MONDAY, 23:59]{PST} starting at [2014-07-15 09:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,776 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [TUESDAY, 11:59]{PST} starting at [2014-07-15 21:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,777 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [TUESDAY, 23:59]{PST} starting at [2014-07-16 09:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,777 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [WEDNESDAY, 11:59]{PST} starting at [2014-07-16 21:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,777 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [WEDNESDAY, 23:59]{PST} starting at [2014-07-17 09:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,777 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [THURSDAY, 11:59]{PST} starting at [2014-07-17 21:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,777 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [THURSDAY, 23:59]{PST} starting at [2014-07-18 09:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,778 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [FRIDAY, 11:59]{PST} starting at [2014-07-18 21:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,779 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each week on [FRIDAY, 23:59]{PST} starting at [2014-07-19 09:59:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,780 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each day on [09:36]{EET} starting at [2014-07-13 09:36:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,780 INFO  [rescheduler:JScheExecutor:84] {cmd /c dir |=> launcher} scheduled for each day on [09:37]{EET} starting at [2014-07-13 09:37:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,780 INFO  [rescheduler:JScheExecutor:84] {cmd /c cd |=> launcher} scheduled for each day on [09:36]{EET} starting at [2014-07-13 09:36:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,780 INFO  [rescheduler:JScheExecutor:84] {cmd /c cd |=> launcher} scheduled for each day on [09:37]{EET} starting at [2014-07-13 09:37:00](local time {Europe/Helsinki})
2014-07-13 01:29:46,780 INFO  [rescheduler:Schedule:137] cmdLine_test.jSche.xml: canceling all executors 2014-07-13 01:29:46,792 INFO  [rescheduler:Schedule:64] cmdLine_test.jSche.xml: setting up executors
2014-07-13 01:29:46,792 INFO  [rescheduler:JScheExecutor:63] cmd /c dir |=> launcher: single execution
2014-07-13 01:29:46,792 INFO  [rescheduler:ProcessExecutor:68] cmd /c dir |=> java application execution
2014-07-13 01:29:46,831 INFO  [rescheduler:ProcessExecutor:112] cmd /c dir: java application execution has ended with exit code 0
2014-07-13 01:29:46,832 INFO  [rescheduler:JScheExecutor:55] cmd /c dir |=> launcher: executors canceled
2014-07-13 01:29:46,832 INFO  [rescheduler:JScheExecutor:63] cmd /c echo Hello, World! |=> launcher: single execution
2014-07-13 01:29:46,832 INFO  [rescheduler:ProcessExecutor:68] cmd /c echo Hello, World! |=> java application execution
2014-07-13 01:29:46,840 INFO  [rescheduler:ProcessExecutor:112] cmd /c echo Hello, World!: java application execution has ended with exit code 0
2014-07-13 01:29:46,840 INFO  [rescheduler:JScheExecutor:55] cmd /c echo Hello, World! |=> launcher: executors canceled
2014-07-13 01:29:46,840 INFO  [rescheduler:Schedule:137] javaApp_test.jSche.xml: canceling all executors
2014-07-13 01:29:46,855 INFO  [rescheduler:Schedule:64] javaApp_test.jSche.xml: setting up executors
2014-07-13 01:29:46,856 INFO  [rescheduler:JScheExecutor:63] TestArguments java application runner: single execution 2014-07-13 01:29:46,856 INFO  [rescheduler:JavaAppRunner:57] TestArguments: java application execution
2014-07-13 01:29:46,857 INFO  [rescheduler:JavaAppRunner:88] TestArguments: java application execution has successfully ended
2014-07-13 01:29:46,857 INFO  [rescheduler:JScheExecutor:55] TestArguments java application runner: executors canceled
2014-07-13 01:30:16,615 INFO  [Thread-6:JSche:86] Stopping the scheduler
2014-07-13 01:30:16,615 INFO  [dirWatcher:DirWatcher:101] JScheSettings directory watcher has been terminated
2014-07-13 01:30:16,616 INFO  [rescheduler:Rescheduler:49] Rescheduler has been terminated
2014-07-13 01:30:16,616 INFO  [rescheduler:Schedule:137] cmdLine.jSche.xml: canceling all executors
2014-07-13 01:30:16,617 INFO  [rescheduler:JScheExecutor:55] cmd /c dir |=> launcher: executors canceled
2014-07-13 01:30:16,617 INFO  [rescheduler:Schedule:140] cmdLine.jSche.xml/cmd /c dir |=> launcher: canceled
2014-07-13 01:30:16,618 INFO  [rescheduler:JScheExecutor:55] cmd /c dir |=> launcher: executors canceled
2014-07-13 01:30:16,618 INFO  [rescheduler:Schedule:140] cmdLine.jSche.xml/cmd /c dir |=> launcher: canceled
2014-07-13 01:30:16,618 INFO  [rescheduler:JScheExecutor:55] cmd /c cd |=> launcher: executors canceled
2014-07-13 01:30:16,618 INFO  [rescheduler:Schedule:140] cmdLine.jSche.xml/cmd /c cd |=> launcher: canceled
2014-07-13 01:30:16,618 INFO  [rescheduler:Schedule:137] cmdLine_test.jSche.xml: canceling all executors
2014-07-13 01:30:16,619 INFO  [rescheduler:Schedule:137] javaApp_test.jSche.xml: canceling all executors
2014-07-13 01:30:16,619 INFO  [Thread-6:JSche:88] The scheduler has successfully ended
2014-07-13 01:30:16,619 INFO  [main:JScheSrv:74] jSche service has successfully ended

Events can be designed as plugins to this module. To extend the utility with new event put the corresponding java executable to the "lib" folder (either classes in full structure or jars) and add event class name to the list of events defined in the eventsClassesHolder.xml. Restart the application.

To run any java executable as event using the <javaAppRunner> add its classes / jars to the "lib" folder, no service restart required to apply that. To run the application define its class in the <startClass> parameter of the <javaAppRunner> event like it is done for the "TestArguments" class example.

Note that the corresponding class TestArguments.class added here for demo purpose, it's free to delete it from here once you've removed the corresponding configuration from the *.jSche.xml configuration files.

Note the developers section to get known how to write your own event plugins.

Note: how to install Java 8.

For those who is not familiar with java: to intall JRE go to JRE download page and download the most recent JRE 8 version of java e.g. now it is 8.201. You can also check if it is already installed on your computer (e.g. "C:\Program Files\Java\jre...") - in this case it is no need to reinstall it.

Installed latest java version and location can be determined automatically via the Windows Registry executing the install_service.bat, update_config.bat or other batches. But in if you want to specify which java implementation to use you can proceed through following steps.

You have 2 manual options to do this.

Option 1. You need to setup JAVA_HOME environment variable to that folder. Press Win+Break (Computer properties), "Advanced system settings", "Advanced" tab, "Environment variables", click "new" in "user variables" section and set the path to your Java installation there:

Option 2. You can also set environment variable directly in batch file used to execute the utility. To do this, edit the "C:\Work\jSche\jScheSrv\compilation\jSche\bin\common_config.bat", and set it as the following in the beginning of the script:

set JAVA_HOME=C:\Program Files\Java\jre...

Questions?

If you have any questions or problems or want to discuss anything else feel free to join or start a discussion on jSche project's forum.