The XS Job File

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"
             }
       }
    ]
}
When defining the job schedule in the  xsjob file, pay particular attention to the entries for the following keywords:
  • 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>",
    NoteYou can also call SQLScripts using the  action keyword.
  • 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.

    TipIn the day field, third from the left, you can use a negative value to count days backwards from the end of the month. For example,  * * -3 * 9 0 0 means: three days from the end of every month at 09:00.
  • * * * * * */5 *
    Every five minutes ( */5) and at any point ( *) within the specified minute.
    NoteUsing the asterisk (*) as a wild card in the seconds field can lead to some unexpected consequences, if the scheduled job takes less than 59 seconds to complete; namely, the scheduled job restarts on completion. If the scheduled job is very short (for example, 10 seconds long), it restarts repeatedly until the specified minute ends.

    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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值