簡體   English   中英

環境路徑-終端OSX

[英]Environment Path - Terminal OSX

我可以直接在終端中運行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`

研究告訴我,這可能是環境問題嗎? 使用Terminal vs cron時如何知道我的路徑?

我正在直接從cron調用Java,crontab類似於:

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

只需在cron中指定整個路徑即可:

輸入“哪個java”

應該輸出類似以下內容:

/usr/bin/java

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM