cron job now working?

Hi all,

I wrote a script as below,

#!/bin/ksh
. /app/home/etc/sudo.profile >/dev/null
 
java -jar $HOME/abc.jar

The jar file abc.jar is located in the same folder as the script.

When I'm manually running that script the jar file gets executed. However if I set a cron job, it seems like the script is still called but that jar file never executes? :wall:

Thanks

instead of $HOME, can you provide the absolute path.

Also, provide the absolute path for java also.

Hi itkamaraj,

I have actually tried that and scheduled a cron job to run the following script,

#!/bin/ksh
. /app/home/etc/sudo.profile >/dev/null
touch <absolute_path>/tmp.txt
java -jar <absolute_path>/abc.jar

The tmp.txt file was created but the abc.jar file was still not executed?

Redirect stdout and stderr to a log file to check what went wrong.

Try having set -x in the script and have the crontab entry like this

* * * * * /full/path/to/your/script >/tmp/log 2>&1

Examine the /tmp/log for any clues.

--ahamed

Hi ahamed,

I got the problem. The output of running that jar file is a csv file. When I manually trigger the script, it understands to save the output file in the current folder. However if being trigger by a cron job, it doesn't know where to save the output file to?

So how could I solve this problem?

May be you need to provide the path where csv needs to be saved in the java code. Try inlcuding "./output.csv" in the jar code as for the file path.

On a second thought, are you sure thats the issue?

--ahamed