cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA - Scheduled job is not triggered

Former Member
0 Kudos
1,953

Dear Experts,

Could you please assist with the issue regarding scheduled job inside of HANA DB.

Seems that all is in place, but for some reasons job is not triggered...

What I done:

1. Set configuration option scheduler/enabled - > true

2. Created xsjob file    

{

  "description":"Notification jobs",

  "action":"services.jobsServiceTest.xsjs::doTest",

  "schedules":[

  {

  "description":"Notification jobs",

  "xscron":"* * * * * * 58"

  }

  ]

}

3. xsjs service code

function doTest() {

  var conn = null;

  try {

  conn = $.db.getConnection();

  var pstmt = conn.prepareStatement("insert into \"xxx\".\"xxx.SFSJob\" (\"JOB_NAME\",\"JOB_TIME\") values (?,?)");

  pstmt.setString(1, "SFS Job");

  pstmt.setString(1, new Date());

  var rs = pstmt.executeQuery();

  pstmt.close();

  } catch (e) {

  } finally {

       if (conn) {

       conn.close();

       }

  }

}

JOBS TABLE content

NAME;                           DESCRIPTION;       ACTION;                                             USER;     LOCALE;     STATUS;     START_TIME;     END_TIME

services::notifications;     Notification jobs;     services.jobsServiceTest.xsjs::doTest;     ?;          ?;               ACTIVE;          ?;                    ?

4.Checked that corresponding records created inside the JOBS and JOB_SCHEDULES tables for the _SYS_XS user

5. Job is not triggered - No records in the JOB_LOG table, no records in the SFSJob table

Could you please advise.

Regards,

Alexander

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Problem is resolved.

In my case:

1. By default job has INACTIVE status unless it marked as ACTIVE via Hana admin console

     In case when I changed the status to Active via sql it did not impact the triggering process, so seems that we can      explicitly Active the job via admin console

2. To see Hana Jobs admin console it is necessary to find the corresponding xsjob file in the applications tree.

     Actually I was expecting to see a separate Jobs Navigation tab (like Trust Manager) for the all Hana jobs defined.

Answers (2)

Answers (2)

Abid_Hussain
Discoverer
0 Kudos

I have same issue and resolve after perform following command on HANA machine.

1.check cron tab job is running or not.

perform following command on HANA machine terminal.

#sudo systemctlstatus cron

2.if service is inactive then perform following command.

#sudo systemctlstart cron

Regards,

Abid

 

 

Former Member
0 Kudos

Hi,

I am facing a similar problem:

Have followed all of the steps from the developer guide (page 469-472): http://help.sap.com/hana/SAP_HANA_Developer_Guide_en.pdf

but the job is not executing, neither it is showing in the JOB Log.

scheduleInsert.xsjob

{

    "description": "Scheduled Insert",

    "action": "sap....appl.services:testInsert.xsjs::insert",

    "schedules": [

        {

            "description": "insert",

            "xscron": "* * * * * * 0:59/10"

        }

    ]

}

sap....appl.services:testInsert.xsjs

$.import("sap....appl.xsjslib",   "dummyInsert");

function insert() {

    var dbConnection      = null;

    var output            = null;

    var bo                = null;

    var payload  = null;

    dbConnection    = $.db.getConnection(); //Get dbConnectionection for DB

    bo              = new $.sap....appl.xsjslib.dummyInsert.Value( dbConnection );

    output          = bo.insertValue(JSON.parse("[\"1\"]"), 10, true);

    dbConnection.close();

    dbConnection    = null;

    bo              = null;

    $.response.status = output.HttpStatusCode;

    $.response.setBody(JSON.stringify(output) + '\n');

}

Thanks & Regards,

Rachit

former_member364339
Discoverer
0 Kudos

Hi,

I have the same problem as Rachit described. The only difference in our case is that we try to run SQLScript from the job. The job is set to active in the XS Admin Console, but the SQLScript is not executed -> the respective DB table does not get the new entries, coming from the SQLScript...

Any advice how to solve the problem will be highly appreciated!

Best regards,
Alex

Former Member
0 Kudos

Hi Alex,

My problem got resolved.

Problem:

  • Job log in XS Admin Tool did not show the Job running.
  • DB table did not get updated as expected.

Solution:

  • Hana SP7 has a bug that the XS Admin tool does not show the running Jobs.
  • Use 'SELECT * FROM _SYS_XS.JOB_LOG ORDER BY finished_at desc' to view the log. <-- Helped me to realize that the Job was actually running.
  • In the xsjs there was $.response.status = 200 which prevented the code to successfully update the DB table.

I hope this helps you.

PS: Do check if you have [scheduler] enabled = true in xsengine

Best regards,

Rachit

former_member364339
Discoverer
0 Kudos

Hi Rachit,

my problem is also resolved now. The reason was funny and simple, but cost some time to find out... Our admin has misspelled the parameter [scheduler] enabled and has written "enable" instead...

After correcting it everything works fine!

Thanks & Best regards,

Alex

Former Member
0 Kudos

Nice..our admin did the same too. That's why I mentioned it in PS.

Best Regards,

Rachit

Former Member
0 Kudos

Hi Alex

    what was the syntax for your SQl script in the xs cron job file. It is not working for me. I get error "Access to source denied". I am using the following syntax in the action keyword "PredictiveA.PredictiveAB:generate.sql" where Predictive A is the root package and while predictive AB is sub-package.

Thanks

Saleem