Operating System - HP-UX
1752667 Members
5673 Online
108788 Solutions
New Discussion юеВ

Re: Cronjob not running even in log showed the activities

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: Cronjob not running even in log showed the activities

>I had changed my cronjob for one task for the test ...
> /home/express/tmp2/BAPIN_APL.out

You also need to redirect stderr by adding: 2>&1

You can also trace your script by adding "set -x" near the top. That way you can find where it is failing.
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

I have put set - x in our script and 2>&1 in the end line of my cronjob.

here the output

Processing /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi
/home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi
+ + pwd
currentdir=/home/express
+ cd /home/express/INTERFACES/express_host
+ ng ng-stats
+ 1> ngtemp 2>& 1
+ cat ngtemp
+ grep NGServerStats
+ 1> ngtemp1
+ [ ! -s ngtemp1 ]
+ java ExpressEdi -load /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi -post BAPIN_APL
+ 1> /dev/null
/home/express/BIN/edi_load_post.sh[33]: java: not found
+ cd /home/express

and i run manually the command in commandline

bahora1(express)$ /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL > /home/express/tmp2/BAPIN_APL.out 2>&1

here the output

Processing /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi
/home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi
+ + pwd
currentdir=/home/express/tmp2
+ cd /home/express/INTERFACES/express_host
+ ng ng-stats
+ 1> ngtemp 2>& 1
+ cat ngtemp
+ grep NGServerStats
+ 1> ngtemp1
+ [ ! -s ngtemp1 ]
+ java ExpressEdi -load /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi -post BAPIN_APL
+ 1> /dev/null
+ cd /home/express/tmp2
Archiving /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/n0028499.edi

For those two log we can spot the problem below when cronjob generating the task

/home/express/BIN/edi_load_post.sh[33]: java: not found

what's that mean?
Appreciate ur guy expertice



Tom Henning
Trusted Contributor

Re: Cronjob not running even in log showed the activities

That mean that when cron runs the script it could not find the java binary. When cron runs a command it does so with a very restricted PATH for the shell that is invoked. From your error message above, it is clear that this path does not include the directory for the java program.

This is the reason Elmar suggested adding your normal shell PATH to the top of the cron script. This should allow the script to execute with the same PATH variable that you typically run in your login shell, which will allow the script to find the java program.
What is it that possesses otherwise sane individuals to change something just because it has not been changed in a while?
Michael Mike Reaser
Valued Contributor

Re: Cronjob not running even in log showed the activities

Tom:> This is the reason Elmar suggested adding your normal shell PATH to the top of the cron script. This should allow the script to execute with the same PATH variable that you typically run in your login shell, which will allow the script to find the java program.


Additionally, you'll likely want to set the SHLIB_PATH and LD_LIBRARY_PATH variables as well. Everything that's automatically set up for your interactive session, say by your /etc/profile, $HOME/.profile, etc., will need to be manually set within each script to be cron'ed.
There's no place like 127.0.0.1

HP-Server-Literate since 1979
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

I can see in my profile is seem like the java path is not configured

export PATH=$PATH:$ORACLE_HOME/bin:$PATH_DEF:/usr/bin/X11

and i added :/opt/java1.5/bin in the last line and everything back to normal.

Your guys efford are really appreciated.
Will close the thread and submit the point.
Thanks all
AMIR
Pratyush Paul_1
Valued Contributor

Re: Cronjob not running even in log showed the activities

Hi - you do not have the shell in the script, in the very 1st line of the shell script hence cron is not going to work, cron does not have a shell to launch this script hence it is not working

add the following

#!/bin/ksh

and try this.

regards

Pratyush
Die Hard
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

It was a great experienced and really appreciate for the helpers.
Dennis Handly
Acclaimed Contributor

Re: Cronjob not running even in log showed the activities

>Pratyush: you do not have the shell in the script, in the very first line of the shell script hence cron is not going to work

This is always a good idea. But cron tells you that it is going to use /usr/bin/sh to execute each script.
OldSchool
Honored Contributor

Re: Cronjob not running even in log showed the activities

You said: "I can see in my profile is seem like the java path is not configured

export PATH=$PATH:$ORACLE_HOME/bin:$PATH_DEF:/usr/bin/X11
and i added :/opt/java1.5/bin in the last line and everything back to normal"

unless the script is run specifically using your profile, this has absolutely nothing to do with the problem you experienced. cron will run the job as the user that "owns" the crontab and it will ignore the environment of that user. the script itself is pretty much responsible for setting up the required environment.