I installed java 18 using this tutorial: https://computingforgeeks.com/install-oracle-java-18-on-ubuntu-debian/ Scripts (.sh) running at reboot from crontab doesn't have any JAVA_HOME and default PATH variables. When I run these scripts manually it works. After rebooting it's the same. I tried putting JAVA_HOME = /opt/jdk-18 PATH=$PATH:$JAVA_HOME/bin to my crontab -e as of this thread : Where can I set environment variables that crontab will use? but now scripts are not even running (in /var/log/syslog there is CMD (sh /script-to-run.sh), manually it works.
Asked
Active
Viewed 660 times
0
-
`JAVA_HOME = /opt/jdk-18` should not have spaces around `=`. Yes that matters. Also, what happens if you set JAVA_HOME in the script (instead of in crontab). – Elliott Frisch May 24 '22 at 00:32
-
I fixed spaces, after adding JAVA_HOME to /etc/environment I see it in the script, but still got: sh: java: command not found – andreasdc May 24 '22 at 00:34
-
`echo $PATH` and make sure `/opt/jdk-18/bin` is there. If it isn't, then you know why. If it is, then do a `which java` where `java` actually works for you. – Elliott Frisch May 24 '22 at 00:41
-
I created symlink with ln -s /opt/jdk-18/bin/java /usr/bin/java and it worked, thanks for help. :) – andreasdc May 24 '22 at 00:49
-
I use (and recommend) [sdkman](https://sdkman.io/). – Elliott Frisch May 24 '22 at 01:08