Last updated: May 25, 2006
Installation and Configuration
Appendix A: Licenses and Acknowledgements
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 3.1.0 or later by following the installation instructions in the STAF documentation.
Download the CronV320.zip/tar file from Get STAF Services 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/cron/STAFCron.jar
where:
Examples:
DESCRIPTION specifies a description of the registration. It is for informational purposes only.
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 PYTHONMACHINE 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 PYTHONSERVICE 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. This option will handle private data.
PYTHONREQUEST specifies the request to be executed. This option will not resolve STAF variables. When the specified time interval occurs, the value of PYTHONREQUEST will be evaluated as a python string. This option will handle private data.
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).
ONCE indicates that the STAF command should only be executed one time. After the specified time interval has occurred and the STAF command has been submitted, the ID for this request will be unregistered.
Note: At least one of the time interval options (MINUTE, HOUR, DAY, MONTH, WEEKDAY) must be specified in a REGISTER request.
Syntax: STAF local CRON REGISTER MACHINE local SERVICE PROCESS REQUEST "START COMMAND notepad" HOUR 1
Syntax: STAF local CRON REGISTER MACHINE local SERVICE PROCESS REQUEST "START COMMAND notepad" HOUR 1 WEEKDAY Sunday
Syntax: STAF local 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.
Syntax: STAF local CRON REGISTER MACHINE local SERVICE stax REQUEST "EXECUTE FILE c:/tests/startall.xml" MONTH 12 DAY "*"
Syntax: 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.
LONG specifies to list more detailed information about each Cron request.
Definition of map class STAF/Service/Cron/CronID | |||
---|---|---|---|
Description: This map class represents a registered Cron request. | |||
Key Name | Display Name | Type | Format / Value |
cronID | ID | <String> | |
machine | Machine | <String> | |
service | Service | <String> | |
request | Request | <String> | Private data will be masked. |
minute | Minute | <String> | <None> | |
hour | Hour | <String> | <None> | |
dayOfMonth | Day of Month (Day) | <String> | <None> | |
month | Month | <String> | <None> | |
dayOfWeek | Day of Week (Weekday) | <String> | <None> | |
once | Once | <String> |
Definition of map class STAF/Service/Cron/CronIDLong | |||
---|---|---|---|
Description: This map class represents a registered Cron request with detailed information. | |||
Key Name | Display Name | Type | Format / Value |
cronID | ID | <String> | |
machine | Machine | <String> | |
machineType | Machine Type | <String> | 'Literal' | 'Python' |
service | Service | <String> | |
serviceType | Service Type | <String> | 'Literal' | 'Python' |
request | Request | <String> | Private data will be masked. |
requestType | Request Type | <String> | 'Literal' | 'Python' |
prepareScript | Prepare Script | <String> | <None> | |
minute | Minute | <String> | <None> | |
hour | Hour | <String> | <None> | |
dayOfMonth | Day of Month | <String> | <None> | |
month | Month | <String> | <None> | |
dayOfWeek | Day of Week | <String> | <None> | |
once | Once | <String> |
Syntax: STAF local CRON LIST
Result: If the request is submitted from the command line, the result, in the verbose format, could look like:
ID Machine Service Request Minute Hour Day Month Weekday Once -- -------- ------- ------------------------- ------ ------ --- ------ -------- ---- 4 local PROCESS START COMMAND notepad <None> 18 <No <None> Friday false ne> 3 server1 STAX EXECUTE FILE c:/tests/run 30 8 ANY <None> <None> false All.xml 2 server1 STAX EXECUTE FILE c:/automate/ <None> 8,12,1 <No <None> Monday,T false updateStatus.xml 5,16,1 ne> uesday,W 7,18,0 ednesday ,Thursda y,Friday 1 client1. process START COMMAND notepad <None> 1 <No <None> <None> false austin.i ne> bm.com
Syntax: STAF local CRON LIST LONG MACHINE server1
Result: If the request is submitted from the command line, the result, in the verbose format, could look like:
[ { ID : 3 Machine : server1 Machine Type : Literal Service : STAX Service Type : Literal Request : EXECUTE FILE c:/tests/runAll.xml Request Type : Literal Prepare Script:Minute : 30 Hour : 8 Day of Month : ANY Month : Day of Week : \ Once : false } { ID : 2 Machine : server1 Machine Type : Literal Service : STAX Service Type : Literal Request : EXECUTE FILE c:/automate/updateStatus.xml Request Type : Literal Prepare Script: Minute : Hour : 8,12,15,16,17,18,0 Day of Month : Month : Day of Week : Monday,Tuesday,Wednesday,Thursday,Friday Once : false } ]
VERSION specifies to display the version level of the Cron service or the version level of Jython packaged with the Cron service.
JYTHON specifies to display the version level of Jython packaged with the Cron service.
Syntax: VERSION
Result: 3.2.0
Syntax: VERSION JYTHON
Result: 2.1-staf-v2
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).
In Cron V3.2.0, the format of this data was modified. Persistent registration data for versions prior to Cron V3.2.0 will automatically be migrated to the new format. Note that the new format can not be used with versions of Cron prior to V3.2.0.
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 a Cron service log on the local machine with machine nickname client1 could look like (shown via a request from the command line in the table format:
C:\>STAF local LOG QUERY MACHINE client1 LOGNAME Cron Response -------- Date-Time Level Message --------- ----- ------------------------------------------------------------- 20060524- Info Register ID=1 originMachine=tcp://client1.austin.ibm.com@6500 00:05:45 machine=client1 pythonMachine=false service=stax pythonServic e=false request=version pythonRequest=false prepare= minute=[ ANY] hour=[] day=[24] month=[] weekday=[] once=false 20060524- Info Register ID=2 originMachine=tcp://client1.austin.ibm.com@6500 00:06:00 machine=client1 pythonMachine=false service=event pythonServi ce=false request=blah pythonRequest=false prepare= minute=[AN Y] hour=[] day=[24] month=[1] weekday=[] once=false 20060524- Info Submitted request #120 ID=2 triggers=minute[6],day[24],month[ 00:06:08 1] machine=client1 service=event request=blah 20060524- Info Submitted request #124 ID=1 triggers=minute[6],day[24] machin 00:06:08 e=client1 service=stax request=version 20060524- Error Request #120: RC=7, Result=blah, Request submitted: machine=c 00:06:08 lient1 service=event request=blah 20060524- Info Request #124: RC=0, Result=1.5.0, Request submitted: machine= 00:06:08 client1 service=stax request=version 20060524- Info Submitted request #142 ID=2 triggers=minute[7],day[24],month[ 00:07:08 1] machine=client1 service=event request=blah 20060524- Info Submitted request #146 ID=1 triggers=minute[7],day[24] machin 00:07:08 e=client1 service=stax request=version 20060524- Error Request #142: RC=7, Result=blah, Request submitted: machine=c 00:07:08 lient1 service=event request=blah 20060524- Info Request #146: RC=0, Result=1.5.0, Request submitted: machine= 00:07:08 client1 service=stax request=version 20060524- Info Unregister ID=1 00:07:44 20060524- Info Unregister ID=2 00:07:45
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.