Last updated: August 15, 2005
Note that Cron registration information is persistent data. This means that if you register with the Cron Service, if you shutdown STAF and restart it (even if you reboot the machine), the prior registration information will still be active. When STAF starts, it reads in the previous Cron registration information, and will execute the registered STAF commands at the specified time interval(s).
Note that the Cron service uses its machine's Operating System date/time information to determine the current date/time in relation to the registered requests. Users of the Cron service must ensure that the machine on which the Cron service is running has the correct Operating System date/time (and that it correctly updates the current date/time relative to Daylight Savings Time).
Install STAF Version 2.6.0 or later (but less than Version 3.0) by following the installation instructions in the STAF documentation.
Download the CronV125.zip/tar file from Download Services for STAF V2 into a local directory (e.g. C:/STAF/services or /usr/local/staf/services) and extract it.
Configure the Cron service:
service <CronName> LIBRARY JSTAF EXECUTE c:/staf/services/STAFCron.jar
where:
Examples:
MACHINE specifies the name of the machine where the command will be executed. This option will resolve STAF variables. When the specified time interval occurs, the value of MACHINE will not be evaluated as a python string.
PYTHONMACHINE specifies the name of the machine where the command will be executed. This option will not resolve STAF variables. When the specified time interval occurs, the value of MACHINE will be evaluated as a python string.
SERVICE specifies the name of the service to be executed. This option will resolve STAF variables. When the specified time interval occurs, the value of SERVICE will not be evaluated as a python string.
PYTHONSERVICE specifies the name of the service to be executed. This option will not resolve STAF variables. When the specified time interval occurs, the value of SERVICE will be evaluated as a python string.
REQUEST specifies the request to be executed. This option will resolve STAF variables. When the specified time interval occurs, the value of REQUEST will not be evaluated as a python string.
PYTHONREQUEST specifies the request to be executed. This option will not resolve STAF variables. When the specified time interval occurs, the value of RQUEST will be evaluated as a python string.
PREPARE
specifies Python code which will be executed when the specified time interval
occurs. This code will be executed prior to the PYTHONMACHINE,
PYTHONSERVICE,
and
PYTHONREQUEST
options being evaluated as python strings. This option will not resolve
STAF variables. If the Python code sets the variable
STAFCronSubmit to any string other than 'true', then the request will
not be submitted.
MINUTE specifies the exact minute(s) that the request executes. The valid values are 0 - 59. You can specify either * (an asterisk) or ANY, meaning all valid values, or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (such as 1-15).
HOUR specifies the exact hour(s) that the request executes. The valid values are 0 - 23. You can specify either * (an asterisk) or ANY, meaning all valid values, or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (such as 8-17).
DAY specifies the exact day(s) that the request executes. The valid values are 1 - 31. You can specify either * (an asterisk) or ANY, meaning all valid values, or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (such as 1-2).
MONTH specifies the exact month(s) that the request executes. The valid values are 1 - 12. You can specify either * (an asterisk) or ANY, meaning all valid values, or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (such as 5-6).
WEEKDAY specifies the exact weekday(s) that the request executes. The valid values are 0 - 6 (Sunday = 0, ....). You can also specify the textual weekday ("Sunday", etc.). You can specify either * (an asterisk) or ANY, meaning all valid values, or a list of elements separated by commas. An element is either a number or an inclusive range, indicated by two numbers separated by a minus sign (such as 1-15).
Note: At least one of the time interval options (MINUTE, HOUR, DAY, MONTH, WEEKDAY) must be specified in a REGISTER request.
cron register machine
local service process request "start command notepad" hour 1
Goal: Execute the command "start command notepad" at 1:00AM every Sunday.
cron register machine
local service process request "start command notepad" hour 1 weekday Sunday
Goal: Execute a STAX job every December 1st.
cron register machine local service stax request "execute file c:/tests/startall.xml" month 12
Note that the registration in this example would only result in the command
being executed the next time the month changes to 12. So, if you
registered this command on Dec 5, 2003, it would not be executed until
12AM Dec 1 2004.
Goal: Execute a STAX job every day in December.
cron register machine
local service stax request "execute file c:/tests/startall.xml" month 12 day *
Goal: Execute a STAX job called C:/automate/updateStatus.xml via
the STAX service on machine server1 every week day (Monday through Friday) at the following times: 8:00AM, 12:00PM,
3:00PM, 4:00PM, 5:00PM, and midnight.
STAF local CRON REGISTER MACHINE server1 SERVICE stax REQUEST "EXECUTE FILE c:/automate/updateStatus.xml" WEEKDAY "Monday-Friday" HOUR "8, 12, 15-18, 0"
ID specifies the Cron ID which is to be unregistered.
MACHINE specifies the machine for which Cron requests should be listed.
2;local;false;process;false;start
command notepad;false;;;;ANY;;;;
1;local;false;process;false;start
command notepad;false;;1;;;;;
The Cron service maintains a machine log where it writes an entry when the following occurs:
The logname for the Cron service is the name under which the service is registered.
Here is an example of what the Cron service log looks like:
java com.ibm.staf.service.cron.CronRegister
A GUI will be displayed which allows you to enter the Cron Registration options.
The "Cron Service Machine" default is the local machine. The "Cron Service Name" default is "Cron".
Fill in the required values for "Target Machine", "Target Service", and "Target Request". Optionally, you may specify Python code in the "Prepare Script" field.
Fill in one or more values for "Minute", "Hour", "Day", "Month", and "Weekday".
This example shows the options you would specify to execute a STAX job at 6:00am every day.
Jython Software License ======================= Copyright (c) 2000, Jython Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Jython Developers nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.