Project and Portfolio Management Practitioners Forum
cancel

Cronjob set for kStatus.sh script doesn't work.

Highlighted
happa
Super Contributor.

Cronjob set for kStatus.sh script doesn't work.

Hello All,

 

Currently we are using PPM 9.14.0002.

 

We dont have any monitoring for PPM.

 

So I want to set a cronjob for running the kStatus.sh script (which gives the status of the application server -"running"/"not running" ).

 

I used the following command:

 

crontab -e
0 4,8,12,16,20,24 * * * cd /..(path)../ppm/bin && sh kStatus.sh

 

The mail goes to the spool and this script gives the following error:

 

"ERROR: JAVA_HOME environment variable is not set :-(.
Please set JAVA_HOME environment variable and try again. "


But the JAVA_HOME variable is already set.

 

Can anyone plaease let me know what I need to do to run the cronjob successfully?

 

Thanks in advance.

 

Best regards,
Santhosh

7 REPLIES
Dennis Handly
Acclaimed Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

>Can anyone let me know what I need to do to run the cronjob successfully?

 

What OS version are you running?  This is related to the OS more than PPM.


>But the JAVA_HOME variable is already set.

 

Why do you think it is set?  If you don't set it in your crontab entry or in kStatus.sh, it won't be set.

crontab bypasses settings made in your ~/.profile.

 

 

happa
Super Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

Hello Dennis,

Thanks for the reply.

Our current OS version is RedHat Linux 5.

I have tried setting the JAVA_HOME in kStatus.sh and in the crontab also, but the result is same.

I guess the issue is not with OS, as I am able to set cronjob for some standard commands like "df -h".

Regards,
Santhosh
Satish_Ganga
Trusted Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

Hi Happa,

 

Try by using the setting temporary variable for JAVA_HOME like set JAVA_HOME=xxxxx.

 

and excute the same script.

 

Regards,

Satish

 

 

 

Dennis Handly
Acclaimed Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

>I have tried setting the JAVA_HOME in kStatus.sh

 

Have you exported it?

export JAVA_HOME=...

Utkarsh_Mishra
Acclaimed Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

Hard code JAVA_HOME variablie in kvariable.sh file.

 

 

For me it is working like this.

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
Jason Nichols K
Acclaimed Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

Something else you may want to look at would adding this to the beginning of the command line of the cron job:

export JAVA_HOME=/path/to/java; [Rest of command goes here]

I've had to do this type of thing many times in the past because cron does not load the .profile.
Dennis Handly
Acclaimed Contributor.

Re: cronjob set for kStatus.sh script doesn't work.

>export JAVA_HOME=/path/to/java; [Rest of command goes here]

 

Or you can just do:

JAVA_HOME=/path/to/java [Rest of command goes here]

>I've had to do this type of thing many times in the past because cron does not load the .profile.

 

Or you can source your .profile:

. ~/.profile; [Rest of command goes here]