java file not running from cron

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



java file not running from cron



I am at directory location /home/oracle/naresh



Files InsertToTable.java, InsertToTable.class, runjava.sh, ojdbc6.jar are at /home/oracle/naresh directory location



InsertToTable.java is a file to insert data in to table. It makes use of ojdbc6.jar at run time. When running the below shell script independently, java will run successfully and data is inserted to table.


runjava.sh
-----------
#!/bin/bash
date >> /home/oracle/naresh/test.txt
export PATH=/home/oracle/jdk1.8.0_151/bin:$PATH
java -cp .:/home/oracle/naresh/ojdbc6.jar InsertToTable
exit 0



When running the same shell script from cron, java file is not running ..



To make sure, whether cron job kicked in or not, I am writing date value to a file and execution of java


crontab:
----------
* * * * * /home/oracle/naresh/runjava.sh



date value is writing to file, when cron is kicked in, but not executing java file. Can some one tell me, how to execute
java file with cron





Possible duplicate of Run simple Java class file with crontab
– Abhinav
Aug 13 at 4:12





You put . on the classpath. What do you believe the current directory is when the script is run by cron? Replace the . with the actual path to where InsertToTable.class is.
– Andreas
Aug 13 at 4:32



.


.


InsertToTable.class





Solved problem, by adding current directory in .sh file , like below ..
– so_nare_0605
Aug 15 at 9:45





cd /home/oracle/naresh
– so_nare_0605
Aug 15 at 9:45









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard