Problem while running CRONTAB
|
Original Message
|
Name: Naga
Date: October 18, 2001 at 02:20:32 Pacific
Subject: Problem while running CRONTAB
|
Comment: I have a requirement where I need to run a helloworld java program in unix environment for every 30 mins. 1. I am using crontab utility for this purpose. 2. My cronfile looks like 0,30 * * * * java helloworld 3. Now when try to run following command, "crontab cronfile" I got an error saying java not found. Now the question is how to set the environment variable to run crontab? Thanks, Naga
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: James Boothe
Date: October 18, 2001 at 07:31:24 Pacific
|
Reply: (edit)Naga, If you run "java helloworld" interactively with no problems, then your session has a PATH that can find java. If you do "which java", it will tell you which executable it is finding. A cron job running as a certain user does not execute that user's .profile, so it does not get the same environment established as your interactive session. You could change your cron entry to a fully-qualified java: 0,30 * * * * /opt/java/bin/java helloworld but I think you will have other environment variables to consider. So have cron run a script instead of a single command: 0,30 * * * * myjavascript and myjavascript will be something like: #!/sbin/sh PATH=$PATH:morepathstuff CLASSPATH=whatever java helloworld echo `date` finished >> myjavascript.log The cron job will run in the user's home directory, which is where I am assuming that helloworld is located. James
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: amit
Date: March 13, 2002 at 03:56:36 Pacific
|
Reply: (edit)hello, i am not still able to solve the problem of crontab as suggested by you(ie how to run a java program from crontab entry) Can u please elaborate on ur answer..i will be grateful regards amit
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: