General
cancel
Showing results for 
Search instead for 
Did you mean: 

Cronjob not running even in log showed the activities

SOLVED
Go to solution
AMIR-APM
Advisor

Cronjob not running even in log showed the activities

We have build HP-UX for test enviroment and the configuration is exactly same with our live production.Everything is goes fine but only cronjob is not running even in the cron log showed the activities.We execute command manually and it's work but failed with crontab.

Here some detail..

# ps -ef|grep cron
root 26628 1 0 11:12:52 ? 0:00 /usr/sbin/cron

Also performed below command but the cronjob still not working

/sbin/init.d/cron stop
/sbin/init.d/cron start

check permission for var\adm\cron ll
total 2016
-r--r--r-- 1 bin bin 51 Mar 26 2004 .proto
prw------- 1 root root 0 Jan 13 15:35 FIFO
-rw-r--r-- 1 root root 972990 Jan 13 11:02 OLDlog
-r--r--r-- 1 bin bin 18 Mar 26 2004 at.allow
-r--r--r-- 1 bin bin 29 Sep 11 14:57 cron.allow
-rw-r--r-- 1 root sys 15728 Jan 13 16:02 log
-r--r--r-- 1 bin bin 17 Mar 26 2004 queuedefs

crontab.allow also we added user to run the crontab but still no luck.

Crontab file
#TO RUN AND PROCESS BAPLIE EXTRACTION FOR MSK
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK

#TO RUN AND PROCESS BAPLIE EXTRACTION FOR APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL

#TO RUN AND PROCESS CODECO EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_MSK

#TO RUN AND PROCESS CODECO EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_APL

#TO RUN AND PROCESS COARRI EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_MSK

#TO RUN AND PROCESS COARRI EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_APL

crontab log

! *** cron started *** pid = 26628 Tue Jan 13 11:12:52 WAT 2009
> CMD: /usr/sbin/sendmail -q
> root 26631 c Tue Jan 13 11:15:00 WAT 2009
< root 26631 c Tue Jan 13 11:15:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK > /dev/null
> express 26722 c Tue Jan 13 11:22:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL > /dev/null
> express 26724 c Tue Jan 13 11:22:00 WAT 2009
< express 26724 c Tue Jan 13 11:22:01 WAT 2009
< express 26722 c Tue Jan 13 11:22:01 WAT 2009
> CMD: /home/express/BIN/edi_session.sh CODECO_MSK > /dev/null
> express 26989 c Tue Jan 13 11:30:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh CODECO_APL > /dev/null
> express 26991 c Tue Jan 13 11:30:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh COARRI_MSK > /dev/null
> express 26993 c Tue Jan 13 11:30:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh COARRI_APL > /dev/null
> express 26994 c Tue Jan 13 11:30:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh COARRI_HLL > /dev/null
> express 26996 c Tue Jan 13 11:30:00 WAT 2009

What should i do now.I have go through the forum but i still can't figure out the solution.Appreciate ur guy help.

Thanks

28 REPLIES
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

more info

# whereis cron
cron: /usr/sbin/cron /usr/share/man/man1m.Z/cron.1m
# ll /usr/sbin/cron
-r-xr-xr-x 1 bin bin 117508 Mar 31 2005 /usr/sbin/cron

# cat cron.allow
root
adm
uucp
express
oracle

# cat log
> CMD: /home/express/BIN/edi_session.sh CODECO_MSK
> express 3266 c Tue Jan 13 16:00:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh CODECO_APL
> express 3268 c Tue Jan 13 16:00:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh COARRI_MSK
> express 3270 c Tue Jan 13 16:00:00 WAT 2009
> CMD: /home/express/BIN/edi_session.sh COARRI_APL
> express 3271 c Tue Jan 13 16:00:00 WAT 2009
> CMD: /usr/sbin/sendmail -q
> root 3274 c Tue Jan 13 16:00:00 WAT 2009
< root 3274 c Tue Jan 13 16:00:00 WAT 2009
< express 3270 c Tue Jan 13 16:00:00 WAT 2009
< express 3266 c Tue Jan 13 16:00:00 WAT 2009
< express 3271 c Tue Jan 13 16:00:00 WAT 2009
< express 3268 c Tue Jan 13 16:00:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK
> express 3354 c Tue Jan 13 16:02:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL
> express 3356 c Tue Jan 13 16:02:00 WAT 2009
< express 3356 c Tue Jan 13 16:02:01 WAT 2009
< express 3354 c Tue Jan 13 16:02:01 WAT 2009
> CMD: /usr/sbin/sendmail -q
> root 3709 c Tue Jan 13 16:15:00 WAT 2009
< root 3709 c Tue Jan 13 16:15:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK
> express 3779 c Tue Jan 13 16:22:00 WAT 2009
> CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL
> express 3781 c Tue Jan 13 16:22:00 WAT 2009
< express 3779 c Tue Jan 13 16:22:01 WAT 2009
< express 3781 c Tue Jan 13 16:22:01 WAT 2009

but the cronjob still not running..
sujit kumar singh
Honored Contributor
Solution

Re: Cronjob not running even in log showed the activities

hi

what is the original coammand line syantax that is Executing successfully from the command line can u tell the whole of the command line that u r able successfully execute from the command line?


Regrds
Sujit
Robert-Jan Goossens_1
Honored Contributor

Re: Cronjob not running even in log showed the activities

Hi,

Did you setup the shell environment for the user? For example the PATH setting.

Robert-Jan
sujit kumar singh
Honored Contributor

Re: Cronjob not running even in log showed the activities

hi and also which normal user is able to excute that complete command successfully from the command line.

Hope that u are not using the root user to execute those commands.


Regards
Sujit
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

There is 6 command line.I have try run all the command manually and works.

1) /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK
2)/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL
3)/home/express/BIN/edi_session.sh CODECO_MSK
4)/home/express/BIN/edi_session.sh CODECO_APL
5)/home/express/BIN/edi_session.sh COARRI_MSK
6)/home/express/BIN/edi_session.sh COARRI_APL
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

i'm using "express" user to execute the command.From the log show u the details.

In cron.allow i also added user express to execute the cronjob
sujit kumar singh
Honored Contributor

Re: Cronjob not running even in log showed the activities

hi


make an entry in the crontab file using the command #crontab -e
and put the following line in there as follows:


0,30 * * * * su - express -c "/home/express/BIN/edi_session.sh CODECO_APL"


try running cron with this entry
and make sure that in the profile of "express" user u have the path added to
/home/express/BIN.
add this path in the pofile of the express user as

PATH=$PATH:/home/express/BIN
export PATH


regards
sujit
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

Hi,

Did you setup the shell environment for the user? For example the PATH setting.

Robert-Jan

Hi robert..
i've run set | grep express and show the path

EXP_PATH=/home/express/bin:/home/express/BIN
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

Hi sujit.

No luck.i've made a changes as below but cronjob still not running

crontab file

bahora1(express)$ crontab -l
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh CODECO_MSK"
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh CODECO_APL"
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh COARRI_MSK"
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh COARRI_APL"
2,22,42 * * * * su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL"
2,22,42 * * * * su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"


log
> CMD: su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL"
> express 5182 c Tue Jan 13 17:22:00 WAT 2009
> CMD: su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"
> express 5184 c Tue Jan 13 17:22:00 WAT 2009
< express 5184 c Tue Jan 13 17:22:02 WAT 2009 rc=9
< express 5182 c Tue Jan 13 17:22:02 WAT 2009 rc=9
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

The best way to troubleshoot the issue is to redirect the output, to check where the script fails

eg:
0,5 * * * * su - express -c "/home/express/BIN/edi_session.sh CODECO_MSK" >> /tmp/CODECO_MSK.out

Then you could check /tmp/CODECO_MSK.out to find out where it fails

Good Luck !!

"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Patrick Wallek
Honored Contributor

Re: Cronjob not running even in log showed the activities

Whose crontab are these jobs running from? Are they running from root or are they runnign from the 'express' user?

Your 'crontab -l' in your last post appears to have been run from the 'express' user.

If they are running as 'express' then your problem is likely the 'su - express' that you are doing.

The only user that will allow the 'su - express -c' syntax to work WITHOUT requesting a password is root.

If you are logged in as express and you try to 'su - express' then you will get prompted for a password. That is probably where your jobs are failing.

If this is really the crontab for the express user then omit the 'su - express -c' from the beginning of each line, and omit the quotes, so that they look like:

0,5 * * * * /home/express/BIN/edi_session.sh CODECO_MSK
0,5 * * * * /home/express/BIN/edi_session.sh CODECO_APL
0,5 * * * * /home/express/BIN/edi_session.sh COARRI_MSK
0,5 * * * * /home/express/BIN/edi_session.sh COARRI_APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK


AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

crontab running from user express.

this is my orginal crontab file which fail in the fist place

Crontab file
#TO RUN AND PROCESS BAPLIE EXTRACTION FOR MSK
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK

#TO RUN AND PROCESS BAPLIE EXTRACTION FOR APL
2,22,42 * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/APL/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_APL

#TO RUN AND PROCESS CODECO EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_MSK

#TO RUN AND PROCESS CODECO EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh CODECO_APL

#TO RUN AND PROCESS COARRI EXTRACTION FOR MSK
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_MSK

#TO RUN AND PROCESS COARRI EXTRACTION FOR APL
0,30 * * * * /home/express/BIN/edi_session.sh COARRI_APL
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

Could you run the cron jobs one at a time.
Let see where it fails
Instead of redirectly the output to /dev/null, please redirect it to a particular file which will allow us to know where it gets failed

Also from the post I could see the the cron logs shows that the script is completed sucessfully

CMD: /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK > /dev/null
> express 26722 c Tue Jan 13 11:22:00 WAT 2009
< express 26722 c Tue Jan 13 11:22:01 WAT 2009

Please correct me ..

The above menthod of redirecting the output to some specific file will exactly let you know how the script goes ..

eg:

* * * * * /home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK > /tmp/BAPIN_MSK.out

Check BAPIN_MSK.out and check if that is what the output your required.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
OldSchool
Honored Contributor

Re: Cronjob not running even in log showed the activities

"home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"

1) fix one at a time...what fixes one will probably fix the others
2) since you're trying to run them as "express" is "express" *allowed* to run cronjobs? check cron.allow
3) in the above, is this *one* job with *three* parms? It looks like it is supposed to be *2* jobs with *2* parms each
4) as noted before...are all the correct environment variables that are needed set within the script. cron strips the environment way down.
5) do any of the above work from the command line, and if so, what *exactly* do you enter?
sujit kumar singh
Honored Contributor

Re: Cronjob not running even in log showed the activities

Hi

yes as oldschool says that , try using the changes that u make on one of the commands only, if that is successful that means that rest are successful.

also from logs it seems that ur cron is able to create the jobs successfully.

try rediredting the O/Ps to some file and see the O/p of those files.

if u want to use -c option as i had said earlier, try running the jobs as root.

also can for one of the commands try to redirect the O/P to some file and compare that O/P with what u get on the screen when u execute the command from the command line.\
This will help u know the difference if that command is running as a cron then where it stops (.... if that stops) as compared to runniug from the commsnd line.

try posting the O/P for an individual command as run from the command line.

Regards
Sujit
Dennis Handly
Acclaimed Contributor

Re: Cronjob not running even in log showed the activities

>I've made a changes as below but cronjob still not running
> CMD: su - express -c "/home/express/BIN/sweep2.sh /home/express/EDI/BAPLIE/MSK/IN/RECEIVAL /home/express/BIN/edi_load_post.sh BAPIN_MSK"
> express 5184 c Tue Jan 13 17:22:00 WAT 2009
< express 5184 c Tue Jan 13 17:22:02 WAT 2009 rc=9

Something is running and got an return code of 9. Probably do to that su that Patrick mentioned.
AMIR-APM
Advisor

Re: Cronjob not running even in log showed the activities

ok..i take ur advise.

i had changed my cronjob for one task for the test

bahora1(express)$ crontab -l

#TO RUN AND PROCESS BAPLIE EXTRACTION FOR APL
2,22,42 * * * * /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

output from BAPIN_APL.out

Processing /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI
/home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI
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

From the file i can't find any error and seem like conjob is running.The only thing is the command not do anything to our application.To be more specific, we are using cronjob as a schedule job to grap edi file sended by our customer and extract all edi information to our application.

i do a test by manually run the command and it's work to our application

bahora1(express)$ /home/express/BIN/edi_load_post.sh BAPIN_APL /home/express/EDI/BAPLIE/APL/IN/RECEIVAL/636942.EDI

crosscheck cron.allow

# cat cron.allow
root
adm
uucp
express
oracle

"express" user is there.

It's quit weird the command from cronjob not effect ou application.Any idea?






Elmar P. Kolkman
Honored Contributor

Re: Cronjob not running even in log showed the activities

Since the command runs from the commandline and not from cron, there are two things to make sure first when the script runs:

The current working directory and the contents of the PATH environment variable.

Try adding the PATH environment variable to the script as the first command (open with vi, go to line 2 (line 1 should read something like #!/usr/bin/sh) and do:
:!set | grep PATH

Close the script.
If that doesn't help, doing a pwd command in the script also helps. But only when you don't redirect anymore to /dev/null. Or have the script itself log.
Every problem has at least one solution. Only some solutions are harder to find.
Avinash20
Honored Contributor

Re: Cronjob not running even in log showed the activities

Also with the above options also add the below line to
/home/express/BIN/edi_load_post.sh

set -x <<--= Add this at the start of the script

This will allow us the know how the script runs and offcourse you need to redirect the output as you are doing

Also the script needs to be more interactive saying what exatly it does

Good Luck !
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
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