0

ターミナルで直接問題なく java -classpath コマンドを実行できますが、cron で実行しようとするとすぐに次のエラーがスローされます。

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`

調査によると、これは環境パスの問題である可能性がありますか? ターミナルと cron を使用する場合、自分のパスを確認するにはどうすればよいですか?

私はcronからJavaを呼び出しています.crontabは次のようなものです:

0 3 * * * * java -classpath /Users/tb582/Desktop/sample1.jar:/Users/tb582......

4

1 に答える 1

0

パス全体をcronで指定するだけです。

「whichjava」と入力します

これに似たものを出力する必要があります:

/usr/bin/java
于 2012-05-18T21:02:44.807 に答える