I'm not familiar with Synology
so fwiw ...
The shell script works when executed at the command line because the particular login session has already loaded a set of environment variables (eg, upon logging in the .profile/.bashrc
script(s) in the home directory is sourced and the various java-specific environment variables are loaded - PATH, JAVA_HOME, CLASSPATH
, etc) that allow java
and the script to run without issue.
The failed Synology
job error indicates that the java-specific environment variables have not been loaded and therefore the job/script is unable to locate java
.
Assuming Synology
does not have a configuration setting/flag that stipulates to pre-load a login's profile, the 'easy' solution would be to edit the script (sms.sh
) and have it source the appropriate resource file before performing any operations (eg, calling java
). A simple example:
$cat sms.sh
#!/usr/bin/bash
. ~root/.bashrc # load the root account profile before continuing ...
java ...
NOTES:
- replace
root
with the name of the login under which the script is to be run (in the example Synology
images it appears you've chosen the root
user hence my example references ~root
)
- replace
~root/.bashrc
with the path to user's profile in order to pre-load the environment variables needed to allow the script to find java
/whatever/path/to/java/is/java /volume1/homes/jar
(this is not specific to synology) – Williwaw