Inquire-save-published-queries tool not working in crontab

Hello ,

We are establishing the Inquire-save-published-queries tool Production setup | Teneo Developers in our environment.

We have done the needful as per the above link and when we are running the below command on command line , its working fine.

/usr/lib/jvm/java-11-jre-amd64/bin/java -jar /tmp/inquire-save-published-queries-6.1.1.jar --config=/tmp/application.conf

But same when we are trying to run in crontab. Its not working. We can see in cronlog that the cmd got run on scheduled time. but we can observed that its didnt get executed.

Further we tried to run the same in a bash script but the results are same.

We tried to source .bashrc file so that all the env variable should get imported but still the same.

We are scheduling the same in crontab as below.

38 23 * * * /bin/bash -x /tmp/script.sh 2>&1 >> /tmp/somelogfile.txt

Request you to please help us to resolve this issue.

Hi @dhaneakshay, welcome to the forum!

Happy to see that you are using the production setup. Could you possibly give me more information related to this? Are you getting some sort of errors, or what is the response when you run the code?

Warm regards,
Ramazan

Hello Ramazan,

Thank you for your response.

Actually we are not getting any error at all. In above crontab entry, you can see we have redirected the output of that script to /tmp/somelogfile.txt but after running that script, nothing is getting updated in that file.

In cron logs, we can see that the script which we scheduled in crontab got triggered on mentioned time but it didnt get executed.

we tried to run the command from another server like trying to pass the command with ssh option like mentioned below . but it didnt get executed.

#ssh root@ -C '/usr/lib/jvm/java-11-jre-amd64/bin/java -jar /data/inquire-save-published-queries-6.1.1.jar --config=/data/application.conf ’

Even we tried to run this command as a service in systemd but that also didnt work.

Further we tried to run this command on the target server using ansible as below

  • hosts: all
    tasks:
    • name: tool
      shell: /usr/lib/jvm/java-11-jre-amd64/bin/java -jar /data/inquire-save-published-queries-6.1.1.jar --config=/data/application.conf >> /data/output.txt

That also didnt work and from snaible logs we can see that the cmd got run but got exist very soon(please refer the start and end time in below logs) without printing any error.

"changed": true,
"cmd": "/usr/lib/jvm/java-11-jre-amd64/bin/java -jar /data/inquire-save-published-queries-6.1.1.jar --config=/data/application.conf >> /data/output.txt",
"delta": "0:00:00.232197",
"end": "2022-11-04 11:45:42.518364",
"invocation": {
    "module_args": {
        "_raw_params": "/usr/lib/jvm/java-11-jre-amd64/bin/java -jar /data/inquire-save-published-queries-6.1.1.jar --config=/data/application.conf >> /data/output.txt",
        "_uses_shell": true,
        "argv": null,
        "chdir": null,
        "creates": null,
        "executable": null,
        "removes": null,
        "stdin": null,
        "stdin_add_newline": true,
        "strip_empty_ends": true,
        "warn": true
    }
},
"rc": 0,
"start": "2022-11-04 11:45:42.286167",
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []

}

So i am suspecting some issue in jar file. Please help to resolve it.

Hi @dhaneakshay,

Thank you for the additional information! I’ve now tested it myself and managed to make it work. This issue seems to occur when you pass the -jar file before the conf file and when the paths might be broken.

Could you possibly follow the structure below and try again?

* * * * * JAVAPATH -Dconfig.file=CONFIGFILE -jar JARFILE

For more reference, this is my code I’m running:
* * * * * /usr/bin/java -Dconfig.file=/Users/rgu0221/Downloads/prod-setup/application.conf -jar /Users/rgu0221/Downloads/prod-setup/inquire-save-published-queries-6.1.1.jar

You can see whether the cronjob works by looking at the version number when you run the script manually:

I’ll update the reference documentation to hold this information as well.

Please let me know how it goes!

Warm regards,
Ramazan

Hello Ramazan,

We executed the cronjob with the mentioned changes by adding the conf directory before jar file and it works.

          • /usr/bin/java -Dconfig.file=/Users/rgu0221/Downloads/prod-setup/application.conf -jar /Users/rgu0221/Downloads/prod-setup/inquire-save-published-queries-6.1.1.jar

Thank you so much for your valuable support.

Regards,
Akshay

2 Likes