We are trying unsuccessfully to run a java command in the following shell script:
#!/bin/bash
/usr/java/jdk1.8.0_91/bin/java -jar /home/cyberren/cyberren/cyberexe/D50_1_Migration.jar > d50Migration.log
We call it with the following line in our cron file:
45 08 * * * /home/cyberren/queries/d50migration.sh
We have confirmed that the shell script runs via cron, but it doesn't execute the java. It tries, but our log output is just this one line:
2016-Jun-30 08:58:11 - D50_1_Migration Process v104
We expect many more lines following such as this:
2016-Jun-30 08:58:11 - D50_1_Migration Process v104
2016-Jun-30 08:58:11 - migrateData -> SQL: UPDATE D50_1 SET xassessment = 192, iStepsTotal = 9 WHERE xIndx = 128
2016-Jun-30 08:58:11 - migrateData -> SQL: UPDATE D50_1 SET xassessment = 192, iStepsTotal = 9 WHERE xIndx = 129
...
We are able to run the same shell script manually, and it executes the java. We are also able to execute the java line manually, and it runs correctly.
So to repeat:
Thanks in advance for the thoughts and advice.
Updates/Additional Info:
cd "$(dirname "$0")" line per Alex's advice. Same output.Solution:
45 08 * * * /bin/bash -l -c "cd /home/cyberren/queries; ./d50migration.sh 2&>1 |tee -a /home/cyberren/d50migration.log" this way you should get to see all output and error output generated (if any) – Finbarr O'Brien 22 mins ago Try setting up the cron job so that it is called from a bash login and sends STDERR output to STDOUT and logs both in a file, this should do it:
45 08 * * * /bin/bash -l -c "cd /home/cyberren/queries; ./d50migration.sh 2>&1 |tee -a /home/cyberren/d50migration.log"
this way you should get to see all output and error output generated (if any)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With