ImagineAdmin / cronnix

Automatically exported from code.google.com/p/cronnix
0 stars 0 forks source link

Help with cronnix and java command #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
why does my java command run and sucessfully exicute when I manually past the 
call that cron is running into terminal yet when I use cronnix 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

Original issue reported on code.google.com by Tony.Bar...@gmail.com on 18 May 2012 at 7:59

GoogleCodeExporter commented 8 years ago
Tony,

judging by the output, your java command is incorrect (it's printing the 
usage). My guess is that either you've got a line break in there somewhere or 
maybe quotes which are swallowed. What does your command look like?

You get the best results with cron if you stick the command in a script, make 
sure it runs even with PATH unset and schedule that script to run from cron.

Hope that helps!

Sven

Original comment by sven.a.s...@gmail.com on 21 May 2012 at 11:14

GoogleCodeExporter commented 8 years ago
Thanks, would I simply copy/paste my command into a text doc and name it 
script.sh ? and have cron run that or is there something else that needs to be 
done?

Original comment by Tony.Bar...@gmail.com on 21 May 2012 at 12:41

GoogleCodeExporter commented 8 years ago
Tony, you copy your command in a script and make it executable (chmod +x 
script.sh). Make sure that all commands are executed with their full path. This 
is critical, because the daemon running this script will have a different 
environment than your user account and therefore may not be able to find the 
commands in your script. For example, you'd write /usr/bin/java instead of just 
java. Similarly for any other commands or paths. Always use full paths, that 
saves you lots of headaches with cron ;)

Original comment by sven.a.s...@gmail.com on 21 May 2012 at 12:47