I can run a java -classpath command without issue directly in terminal but as soon as I try to do it in cron it throws this error:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available (implies -server, only for x86_64)
-client to select the "client" VM
-server to select the "server" VM
-jvm is a synonym for the "client" VM [deprecated]
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output`
Research has told me that this might be an environment path issue? How do I tell what my path is when using terminal vs cron?
I'm envoking java right from cron, crontab is something like:
0 3 * * * * java -classpath /Users/tb582/Desktop/sample1.jar:/Users/tb582......
just specify the whole path in cron:
type "which java"
should output something similar to this:
/usr/bin/java
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.