The .xsjob file defines the details of a task that you want to run (for example, an XS JavaScript or an SQLScript) at a scheduled interval.
The XS job file uses a cron-like syntax to define the schedule at which the service defined in an XS JavaScript or SQLScript must run, as you can see in the following example, which runs the specified job (the stock-price checking service yahoo.xsjs) on the 59th second minute of every minute.
{ "description": "Read stock value", "action": "yahoo:yahoo.xsjs::readStock", "schedules": [ { "description": "Read current stock value", "xscron": "* * * * * * 59", "parameter": { "stock": "SAP.DE" } } ] }
- action
Text string used to specify the path to the function to be called as part of the job.
"action": "<package_path>:<XSJS_Service>.xsjs::<FunctionName>",
- description
Text string used to provide context when the XSjob file is displayed in the SAP HANA XS Administrationtool.
- xscron
The schedule for the specified task (defined in the “action” keyword); the schedule is defined using cron-like syntax.
- parameter
A value to be used during the action operation. In this example, the parameter is the name of the stockSAP.DE provided as an input for the parameter (stock) defined in the readStock function triggered by thexsjob action. You can add as many parameters as you like as long as they are mapped to a parameter in the function itself.
The following examples illustrate how to define an xscron entry including how to use expressions in the variousxscron entries (day, month, hour, minutes,...):
- 2013 * * fri 12 0 0
Every Friday of 2013 at 12:00 hours
- * * 3:-2 * 12:14 0 0
Every hour between 12:00 and 14:00 hours on every day of the month between the third day of the month and the second-last day.
- * * * * * */5 *
Every five minutes ( */5) and at any point ( *) within the specified minute.
To prevent short-running jobs from restarting on completion, schedule the job to start at a specific second in the minute. For example, * * * * * */5 20 indicates that the scheduled job should run every five minutes and, in addition, at the 20th second in the specified minute.
- * * * -1.sun 9 0 0
Every last Sunday of a month at 09:00 hours