1 |
Walt Rarus writes: |
2 |
|
3 |
> I have a java (clojure, actually) program which is invoked via a bash |
4 |
> script. When the script is invoked from the shell, the java program |
5 |
> always runs and succeeds. However, when the script is invoked via a |
6 |
> cron job, the java program always runs and crashes with a null pointer |
7 |
> exception. |
8 |
|
9 |
Cron jobs have a limited environment. The $PATH is shorter, many |
10 |
environment variables are not set. Maybe this is the cause? |
11 |
|
12 |
> Any thoughts on how to debug the situation? |
13 |
|
14 |
I would add "env > /tmp/myscript.env" to the top of the script, this puts |
15 |
all environment variables and their values into /tmp/myscript.env. Compare |
16 |
the outputs with diff, maybe you spot something which explains the |
17 |
behaviour. |
18 |
|
19 |
Maybe you can replace the call to the script in your crontab with |
20 |
something like "bash -il /path/to/myscript", forcing it to run in an |
21 |
interactive login shell. I have not tried this, though, it's just an idea. |
22 |
|
23 |
Wonko |